1st

                Never    
Java
       
import java.awt.*;import java.awt.event.*; import javax.swing.*; import javax.swing.event.*;class A extends JFrame implements ActionListener { JLabel l1, l2, l3;JTextField tf1, tf2, tf3; JButton b1;12A() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new FlowLayout();l1 = new JLabel("Welcome"); setSize(800, 400);l1 = new JLabel("Enter Number1"); add(l1);tf1 = new JTextField(10); add(tf1);l2 = new JLabel("Enter Number2"); add(l2);tf2 = new JTextField(10); add(tf2);l3 = new JLabel("Result"); add(l3);tf3 = new JTextField(10); add(tf3);b1 = new JButton("Divide"); add(b1);b1.addActionListener(this);setVisible(true);}public void actionPerformed(ActionEvent ae) {try {int a = Integer.parseInt(tf1.getText()); int b = Integer.parseInt(tf2.getText()); if(b==0)throw new ArithmeticException(" Divide by Zero Error"); float c = (float) a / b;tf3.setText(String.valueOf(c));} catch (NumberFormatException ex) {13JOptionPane.showMessageDialog(this,ex.getMessage()); }catch (ArithmeticException ex) { JOptionPane.showMessageDialog(this, ex.getMessage());}}}public class JavaApplication{ public static void main(String[] args) { A a = new A();}}

22222222
abstract class shape{ public int x, y;public abstract void printArea();}class Rectangle extends shape { public void printArea() {System.out.println("Area of Rectangle is " + x * y);}17}class Triangle extends shape {public void printArea() {System.out.println("Area of Triangle is " + (x * y) / 2);}}class Circle extends shape {public void printArea() {System.out.println("Area of Circle is " + (22 * x * x) / 7);}}public class Abstex {public static void main(String[] args) {Rectangle r = new Rectangle ();r.x = 10;r.y = 20;r.printArea();System.out.println ("-------------------------------------");Triangle t = new Triangle ();t.x = 30;t.y = 35;t.printArea();System.out.println ("-------------------------------------");Circle c = new Circle ();c.x = 2;c.printArea();System.out.println ("-------------------------------------");}}

Raw Text