class AB
{
public static void main(String args[])
{
int a = 5;
int b = 2;
int p;
int r;
r = a * b;
p = a ++ b;
System.out.println(" result is= " + r);
System.out.println(" result is= " + p );
System.out.println(" result is= " + (a - b) );
}
}
class AB12
{
public static void main(String args[])
{
int a = 5;
int b = 2;
int p;
int r;
r = a * b;
p = a + b;
System.out.println(" result is= " + r);
System.out.println(" result is= " + p );
System.out.println(" result is= " + (a - b) );
}
}
import javax.swing.*;
abstract class person
{
abstract void speak();
}
class tea extends person
{
void speak()
{
JOptionPane.showMessageDialog(null, " Teacher");
System.out.println("Teacher");
}
}
class st extends person
{
void speak()
{
JOptionPane.showMessageDialog(null, "Student");
System.out.println("Student");
}
}
class doc extends person
{
void speak()
{
JOptionPane.showMessageDialog(null, " Doctor");
System.out.println("Doctor");
}
}
class abst00
{
public static void main(String app[])
{
person r;
r = new tea();
r.speak();
r = new st();
r.speak();
r = new doc();
r.speak();
}
}
class A
{
private int a;
int b;
void set(int p)
{
a = p;
}
void show()
{
System.out.println("a ,b , is = " +" " + a );
System.out.println("a ,b , is = " +" " + b );
}
}
class Acc
{
public static void main (String app[])
{
A ob = new A();
ob.b = 6;
ob.set(6);
ob.show(); // without show programm will not run
}
}
class object
{
public int a;
public int b;
private int c;
void show()
{
System.out.println("a is = " + a);
System.out.println("b is = " + b);
System.out.println("c is = " + c);
}
void set(int p)
{
c = p;
}
}
class ACC0
{
public static void main(String app[])
{
object ob = new object();
ob.a = 2;
ob.b = 3;
//sob.c = 5; will produce error
ob.set(4);
ob.show();
}
}
class object
{
private int a;
int b;
void show()
{
System.out.println("A IS = " + a);
System.out.println("B IS = " + b);
}
void set(int p)
{
a= p ;
}
}
class acc1
{
public static void main(String app[])
{
object ob = new object();
ob.b = 7;// if ob.show is 1st then error = A is = 0, B is = 7
ob.set(77);
ob.show();
}
}
class A
{
int a;
int b;
private void show()
{
System.out.println(" Value of A and B is = " + a + " , " + b);
}
void callshow()
{
show();
}
}
class acc2
{
public static void main(String app[])
{
A ob = new A();
ob.a = 2;
ob.b = 3;
ob. callshow();// call or show k darmian space nhi honi hai
}
}
class A
{
int a;
int b;
private int c;
private void show()
{
System.out.println("Value of A, B, C is = " + a + " , " + b + " , " + c);
}
void c(int p)
{
c = p;
}
void callshow()
{
show();
}
}
class acc3
{
public static void main(String app[])
{
A ob = new A();
ob.a = 2;
ob.b = 3;
ob.c(4);
ob.callshow();
}
}
class acce
{
int a;
int b;
private int c;
void show()
{
System.out.println(" Value of a = " + a );
System.out.println(" Value of b = " + b );
System.out.println(" Value of c = " + c );
}
void set(int p) // space b/w int and p
{
c = p;
}
private void sum() // void is necessory
{
System.out.println(" Sum of a,b,c is = " + ( a + b + c ) );
}
void meth()
{
sum();// comass are necessory
}
}
class acc4
{
public static void main(String app[])
{
acce ob = new acce();
ob.a = 2;
ob.b = 3;
ob.set(4);
ob.show();
ob.meth();
}
}
import java.awt.Graphics;
import java.awt.Font;
import java.awt.Color;
public class App extends Applet
{
Font f = new Font("TimesRoman",Font.BOLD,36);
public void paint(Graphics g) {
g.setFont(f);
g.setColor(Color.red);
g.drawString("Hello again", 5, 50);
}
}
import java.awt.*;
import java.applet.*;
public class Applet1 extends Applet
{
public void paint(graphics g)
{
g.drawString("A Simple Applet" , 20, 20);
}
}
import javax.swing.*;
class az
{
public static void main(String args[])
{
int a;
String in;
in = JOptionPane.showInputDialog("Enter the number");
a = Integer.parseInt(in);
if(a%2==0)
System.out.println("The square is :" + a * a);
}
}
class math
{
int a,b;
void cal()
{
String in;
in=JOptionPane.showInputDialog("Enter a=");
a=Integer.pasreInt(in);
in=JOptionPane.showInputDialog("Enter b=");
b=Integer.parseInt(in);
}
}
class add extends math
{
void cal()
{
JOptionPane.showMessageDialog("sum="+(a+b));
}
}
class minus extends add
{
void cal{
JOptionPane.showMessageDialog("minus="+(a-b));
}
}
class multiply extends minus
{
void cal{
JOptionPane.showMessageDialog("multipl="+(a*b))
}
class cr
{
public static void main(String args[])
{
math ob=new math();
ob.cal();
}
}
class abc
{
JFrame f;
JButton b;
void cal()
{
f=new JFrame();
Container c=f.getContentPane();
c.setLayout(new FlowLayout());
b=new JButton("OK");
c.add(b);
f.setSize(200,200);
f.setVisible(true);
f.setResizable(false);
}
}
class GUI17
{
public static void main(String asd[])
{
abc ob=new abc();
ob.cal();
}
}
class Ex
{
public static void main(String []a)
{
int c =2;
int d=0;
try
{
System.out.println("show="+(c/d));
}
catch(arithmaticException e)
{
System.out.println("show error");
}
}
}
import javax.swing.*;
class f
{
public static void main(String args[])
{
int a;
int b;
int s;
String in;
in = JOptionpane.showInputDialog("Enter the number a=")
a = Integer.IarseInt(in);
in = JOptionpane.showInputDialog("Enter the number b=")
b = Integer.parseInt(in);
s = a + b;
System.out.println("sum = " + s);
}
}
import javax.swing.*;
class fd
{
public static void main(String args[])
{
int a;
int c;
String in;
in = JOptionPane.showInputDialog("enter any number:");
a = Integer.parseInt(in);
for(c = 1;c<=10;c++);
{
System.out.println(a + "*" + c + "=" + a*c);
}
}
}
class four
{
public static void main(String args[])
{
int a = 1;
int b = 2;
int c = 3;
int d = 4;
int s;
int mul;
s = a + b;
mul = c * d;
System.out.println("SUM IS " + s);
System.out.println("MUL IS " + mul);
}
}
class fun
{
public static void main(String app[])
{
int a,b,c,d = 1;
System.out.println(" * * *");
System.out.println(" * 0 0 *");
System.out.println(" * *");
for(a=1;a<2;a++)
{
System.out.println(" * ---- *");
}
System.out.println(" * * *");
for(b=1;b<3;b++)
{
System.out.println(" * ");
}
System.out.println(" *** ***");
System.out.println(" * *");
System.out.println(" * *");
System.out.println(" * *");
for(c=1;c<6;c++)
{
System.out.println(" *********");
}
for(d=1;d<5;d++)
{
System.out.println(" * *");
}
System.out.println(" ** **");
}
}
import javax.swing.*;
class g
{
public static void main(String args[])
{
int a;
int b;
int s;
String in;
in = JOptionPane.showInputDialog("Enter a:");
a = Integer.parseInt(in);
in = JOptionPane.showInputDialog("Enter b:");
b = Integer.parseInt(in);
s = a + b;
JOptionPane.showInputDialog(null,"sum="+s);
}
}
import java.awt.*;
import javax.swing.*;
class guit
{
JFrame f;
JButton b;
JButton b1;
JButton b2;
JButton b3;
JTextField t;
void creatgui()// no spacing
{
f = new JFrame();// ;
Container c = f.getContentPane();
c.setLayout(new FlowLayout());
t = new JTextField(20);//no spacing
t = new JTextField(20);
b = new JButton("Button");// no spacing
b1 = new JButton("Button1");
b2 = new JButton("Button2");
b3 = new JButton("+");
c.add(t);// small t instead T
c.add(b);
c.add(b1);
c.add(b2);
c.add(b3);
f.setSize(100,100);// no spacing
// see f and S
f.setVisible(true);
// see f and V
}
}
class GUI
{
public static void main(String app[])
{
guit g = new guit();
g.creatgui();// .
// no pass
}
}
import java.awt.*;
import javax.swing.*;
class guit
{
JFrame f;
JButton b;
JButton b1;
JButton b2;
JButton b3;
JTextField t;
void creatgui()// no spacing
{
f = new JFrame();// ;
Container c = f.getContentPane();
c.setLayout(new FlowLayout());
t = new JTextField(20);//no spacing
t = new JTextField(20);
b = new JButton("Button");// no spacing
b1 = new JButton("Button1");
b2 = new JButton("Button2");
b3 = new JButton("+");
c.add(t);// small t instead T
c.add(b);
c.add(b1);
c.add(b2);
c.add(b3);
f.setSize(100,100);// no spacing
// see f and S
f.setVisible(true);
// see f and V
}
}
class guit1 extends guit
{
void new()
{
JButton b4;
b4 = new JButton("B4");
c.add(b4);
}
}
class GUI1
{
public static void main(String app[])
{
guit g = new guit();
g.creatgui();// .
guit1 k = new guit1();
k.new();
k.creatgui();
// no pass
}
}
import javax.swing.*;
import java.awt.*;
class g
{
JLabel L;
JFrame F;
JButton B1,B2,B3,B4,B5,B6,B7,B8,B9,B10,B11,B12,B13,B14,B15,B16;
JTextField T;
void creat()
{
L=new JLabel("Calculator"); L.setForeground(Color.ORANGE);
L.setFont(new Font("Serif",Font.PLAIN,25));
F=new JFrame("Shahzad's Calculater"); F.setBackground(Color.PINK);
Container C=F.getContentPane();
C.setLayout(new BorderLayout());
JPanel P=new JPanel();
P.setLayout(new GridLayout(4,4,10,15));
P.setBackground(Color.BLACK);//pink
T=new JTextField(20); T.setFont(new Font("Serif",Font.PLAIN,25));
B1=new JButton("1"); B1.setBackground(Color.RED); B1.setForeground(Color.BLACK);
B2=new JButton("2"); B2.setBackground(Color.ORANGE); B2.setForeground(Color.WHITE);
B3=new JButton("3"); B3.setBackground(Color.ORANGE); B3.setForeground(Color.WHITE);
B4=new JButton("4"); B4.setBackground(Color.ORANGE); B4.setForeground(Color.WHITE);
B5=new JButton("5"); B5.setBackground(Color.RED); B5.setForeground(Color.WHITE);
B6=new JButton("6"); B6.setBackground(Color.ORANGE); B6.setForeground(Color.WHITE);
B7=new JButton("7"); B7.setBackground(Color.ORANGE); B7.setForeground(Color.WHITE);
B8=new JButton("8"); B8.setBackground(Color.ORANGE); B8.setForeground(Color.WHITE);
B9=new JButton("9"); B9.setBackground(Color.RED); B9.setForeground(Color.WHITE);
B10=new JButton("0"); B10.setBackground(Color.ORANGE); B10.setForeground(Color.WHITE);
B11=new JButton("c"); B11.setBackground(Color.ORANGE); B11.setForeground(Color.WHITE);
B12=new JButton("="); B12.setBackground(Color.ORANGE); B12.setForeground(Color.WHITE);
B13=new JButton("+"); B13.setBackground(Color.ORANGE); B13.setForeground(Color.WHITE);
B14=new JButton("-"); B14.setBackground(Color.ORANGE); B14.setForeground(Color.WHITE);
B15=new JButton("/"); B15.setBackground(Color.RED); B15.setForeground(Color.WHITE);
B16=new JButton("x"); B16.setBackground(Color.ORANGE); B16.setForeground(Color.WHITE);
P.add(B1);
P.add(B2);
P.add(B3);
P.add(B13);
P.add(B4);
P.add(B5);
P.add(B6);
P.add(B14);
P.add(B7);
P.add(B8);
P.add(B9);
P.add(B16);
P.add(B10);
P.add(B11);
P.add(B12);
P.add(B15);
C.add(T,BorderLayout.NORTH);
C.add(L,BorderLayout.SOUTH);
C.add(P,BorderLayout.CENTER);
F.setSize(400,400);
F.setVisible(true);
}
}
class GUI2
{
public static void main(String asd[])
{
g r=new g();
r.creat();
}
}
import java.awt.*;
import javax.swing.*;
class gui
{
JFrame f;
JButton b;
JTextField t;
void creat()
{
f = new JFrame();
Container c = f.getContentPane();//p Capital
c.setLayout(new FlowLayout());
t = new JTextField(10);
b = new JButton("BUTTON");
c.add(t);
c.add(b);
f.setSize(200,200);
f.setVisible(true);
}
}
class GUI3
{
public static void main(String app[])
{
gui g = new gui();
g.creat();
}
}
import java.awt.*;
import javax.swing.*;
class gui
{
void ggg()
{
JFrame f;
JButton b;
JButton b1;
JButton b2;
JTextField t;
f = new JFrame();
Container c = f.getContentPane();
c.setLayout(new GridLayout(2,1,200,200));
t = new JTextField(5);
b = new JButton("b");
b1 = new JButton("b1");
b2 = new JButton("b2");
c.add(t);
c.add(b);
c.add(b1);
c.add(b2);
f.setSize(100,100);
f.setVisible(true);
}
}
class GUI4
{
public static void main(String args[])
{
gui g = new gui();
g.ggg();
}
}
import java.awt.*;
import javax.swing.*;
class m
{
JFrame f;
JButton b; JButton b1; JButton b2; JButton b3; JButton b4; JButton b5; JButton b6; JButton b7; JButton
b8; JButton b9; JButton b10; JButton b11; JButton b12; JButton b13; JButton b14;
JTextField t;
void method()
{
f = new JFrame();
Container c = f.getContentPane();
c.setLayout(new BorderLayout());
t = new JTextField(5);
b = new JButton("0");
b1 = new JButton ("1");
b2 = new JButton ("2");
b3 = new JButton ("3");
b4 = new JButton ("4");
b5 = new JButton ("5");
b6 = new JButton ("6");
b7 = new JButton ("7");
b8 = new JButton ("8");
b9 = new JButton ("9");
b10 = new JButton ("*");
b11 = new JButton ("/");
b12 = new JButton ("+");
b13 = new JButton ("-");
b14 = new JButton ("ReSet");
c.add(t, BorderLayout.NORTH);
c.add(b, BorderLayout.EAST);
c.add(b1, BorderLayout.WEST);
c.add(b2, BorderLayout.SOUTH);
c.add(b3, BorderLayout.CENTER);
c.add(b4, BorderLayout.EAST);
c.add(b5);
c.add(b6);
c.add(b7);
c.add(b8);
c.add(b9);
c.add(b10);
c.add(b11);
c.add(b12);
c.add(b13);
c.add(b14);
f.setSize(100,100);
f.setVisible(true);
}
}
class GUI5
{
public static void main(String args[])
{
m g = new m();
g.method();
}
}
import java.awt.*;
import javax.swing.*;
public class CalculatorGUI {
JFrame fCalc;
JButton b1, b2, b3, b4, b5, b6, b7, b8, b9, b0;
JButton bPlus, bMinus, bMul, bPoint, bEqual, bClear;
JPanel pButtons;
JTextField tfAnswer;
JLabel lMyCalc;
public void initGUI ( ) { //used for setting layout of calculator
fCalc = new JFrame();
b0 = new JButton("0");
b1 = new JButton("1");
b2 = new JButton("2");
b3 = new JButton("3");
b4 = new JButton("4");
b5 = new JButton("5");
b6 = new JButton("6");
b7 = new JButton("7");
b8 = new JButton("8");
b9 = new JButton("9");
bPlus = new JButton("+");
bMinus = new JButton("-");
bMul = new JButton("*");
bPoint = new JButton(".");
bEqual = new JButton("=");
bClear = new JButton("C");
tfAnswer = new JTextField();
lMyCalc = new JLabel("My Clacualator");
//creating panel object and setting its layout
pButtons = new JPanel (new GridLayout(4,4));
//adding components (buttons) to panel
pButtons.add(b1);
pButtons.add(b2);
pButtons.add(b3);
pButtons.add(bClear);
pButtons.add(b4);
pButtons.add(b5);
pButtons.add(b6);
pButtons.add(bMul);
pButtons.add(b7);
pButtons.add(b8);
pButtons.add(b9);
pButtons.add(bMinus);
pButtons.add(b0);
pButtons.add(bPoint);
pButtons.add(bPlus);
pButtons.add(bEqual);
Container con = fCalc.getContentPane();
con.setLayout(new BorderLayout());
//adding components to container
con.add(tfAnswer, BorderLayout.NORTH);
con.add(lMyCalc, BorderLayout.SOUTH);
con.add(pButtons, BorderLayout.CENTER);
fCalc.setSize(300, 300);
fCalc.setVisible(true);
} // end of initGUI method
//default constructor
public CalculatorGUI ( ) {
initGUI();
}
//main method
class GUI6
{
public static void main(String args[ ])
{
CalculatorGUI calGUI = new CalculatorGUI();
}
}
import java.awt.*;
import javax.swing.*;
class gui
{
JFrame f;
JTextField t;
JButton b;
void gui()
{
f = new JFrame();
Container c = f.getContentPane();
c.setLayout(new FlowLayout());
b = new JButton("Button");
t = new JTextField(10);
c.add(b);
c.add(t);
f.setSize(1,1);
f.setVisible(true);
}
}
class GUI7
{
public static void main (String app[])
{
gui p = new gui();
p.gui();
}
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class gui
{
JFrame f = new JFrame();
JTextField t = new JTextField(20);
JButton b = new JButton("B");
JButton b1 = new JButton("B1");
void g ()
{
Container c = f.getContentPane();
c.setLayout(new FlowLayout());
c.add(t);
c.add(b);
c.add(b1);
t.setBounds(10,10,10,10);
b.setBounds(10,10,10,10);
b1.setBounds(10,10,10,10);
f.setVisible(true);
f.setSize(100,100);
b.addActionListener(new bAct());
}
public class bAct implements ActionListener
{
public void actionPerformed(ActionEvent e)// public is necessory
{
String n = "1";
t.setText(n);
}
}
}
class GUI8
{
public static void main(String app[])
{
gui ob = new gui();
ob.g();
}
}
import javax.swing.*;
import java.awt.*;
class gui
{
JFrame f;
JTextField t,t1,t2,t3,t4,t5,t6;
JButton b,b1,b2,b3;
void g()
{
f = new JFrame();
Container c = f.getContentPane();
c.setLayout(new GridLayout(2,3));
t = new JTextField(10);
t1 = new JTextField(10);
t2 = new JTextField(10);
t3 = new JTextField(10);
t4 = new JTextField(10);
t5 = new JTextField(10);
t6 = new JTextField(10);
c.add(t);
c.add(t1);
c.add(t2);
c.add(t3);
c.add(t4);
c.add(t5);
c.add(t6);
b = new JButton("BUTTON");
b1 = new JButton("B1");
b2 = new JButton("b2");
b3 = new JButton("b3");
c.add(b1);
c.add(b2);
c.add(b3);
f.setSize(100,100);
f.setVisible(true);
}
}
class GUI9
{
public static void main(String app[])
{
gui ob = new gui();
ob.g();
}
}
import javax.swing.*;// libraries
import java.awt.*;
class gui
{
JFrame f;
JButton b;
JButton b1;
JButton b2;
JButton b3;
JButton b4;
void g()
{
f = new JFrame();
Container c = f.getContentPane();
c.setLayout(new BorderLayout());
b = new JButton("b");
b1 = new JButton("b1");
b2 = new JButton("b2");
b3 = new JButton("b3");
b4 = new JButton("b4");
c.add(b, BorderLayout.NORTH);
c.add(b1, BorderLayout.SOUTH);
c.add(b2, BorderLayout.EAST);
c.add(b3, BorderLayout.WEST);
c.add(b4, BorderLayout.CENTER);
f.setSize(100,100);
f.setVisible(true);
}
}
class GUI10
{
public static void main(String app[])
{
gui ob = new gui();
ob.g();
}
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class gui implements ActionListener
{
JFrame f=new JFrame();
JButton b1,b2,b3,b4;
JTextField t1,t2;
void gg()
{
Container c = f.getContentPane();
c.setLayout(new FlowLayout());
b1= new JButton("+");
b2= new JButton("-");
b3= new JButton("*");
b4= new JButton("%");
t1= new JTextField(20);
t2 = new JTextField(20);
c.add(t1);
c.add(t2);
c.add(b1);
c.add(b2);
c.add(b3);
c.add(b4);
f.setSize(400,400);
f.setVisible(true);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
Double x,y,z;
if (e.getSource()==b1)
{
x = Double.parseDouble(t1.getText() );
y = Double.parseDouble(t2.getText());
z = x+ y;
JOptionPane.showMessageDialog(null, "Ans" + z);
}
else if(e.getSource()==b2)
{
//2=t2.getText();
x = Double.parseDouble(t1.getText() );
y = Double.parseDouble(t2.getText());
z = x+ y;
JOptionPane.showMessageDialog(null, "Ans" + z);
}
else if(e.getSource()==b3)
{
x = Double.parseDouble(t1.getText() );
y = Double.parseDouble(t2.getText());
z = x+ y;
JOptionPane.showMessageDialog(null, "Ans" + z);
}
else if(e.getSource()==b4)
{
x = Double.parseDouble(t1.getText() );
y = Double.parseDouble(t2.getText());
z = x+ y;
JOptionPane.showMessageDialog(null, "Ans" + z);
}
}
}
class GUI11
{
public static void main(String app[])
{
gui ob = new gui();
ob.gg();
}
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class abc
{
String dis="";
char result;
double num1,num2;
JFrame f;
JLabel l=new JLabel("Calculator");
JTextField t;
JButton b1,b2,b3,b4,b5,b6,b7,b8,b9,b0,bp,bs,bm,bd,bc,beq;
abc()
{
f=new JFrame();
Container c=f.getContentPane();
c.setLayout(new BorderLayout());
t=new JTextField(10);
JPanel p=new JPanel(new GridLayout(4,4,2,2));
b1=new JButton("1");
b2=new JButton("2");
b3=new JButton("3");
b4=new JButton("4");
b5=new JButton("5");
b6=new JButton("6");
b7=new JButton("7");
b8=new JButton("8");
b9=new JButton("9");
b0=new JButton("0");
bp=new JButton("+");
bs=new JButton("-");
bm=new JButton("*");
bd=new JButton("/");
beq=new JButton("=");
bc=new JButton("c");
p.add(b1);
p.add(b2);
p.add(b3);
p.add(bp);
p.add(b4);
p.add(b5);
p.add(b6);
p.add(bs);
p.add(b7);
p.add(b8);
p.add(b9);
p.add(bm);
p.add(beq);
p.add(b0);
p.add(bc);
p.add(bd);
c.add(t,BorderLayout.NORTH);
c.add(p,BorderLayout.CENTER);
c.add(l,BorderLayout.SOUTH);
f.setSize(400,400);
f.setVisible(true);
//f.setResizable(false);
button1 ob1=new button1();
b1.addActionListener(ob1);
button2 ob2=new button2();
b2.addActionListener(ob2);
button3 ob3=new button3();
b3.addActionListener(ob3);
button4 ob4=new button4();
b4.addActionListener(ob4);
button5 ob5=new button5();
b5.addActionListener(ob5);
button6 ob6=new button6();
b6.addActionListener(ob6);
button7 ob7=new button7();
b7.addActionListener(ob7);
button8 ob8=new button8();
b8.addActionListener(ob8);
button9 ob9=new button9();
b9.addActionListener(ob9);
buttonp obp=new buttonp();
bp.addActionListener(obp);
buttons obs=new buttons();
bs.addActionListener(obs);
buttonm obm=new buttonm();
bm.addActionListener(obm);
buttond obd=new buttond();
bd.addActionListener(obd);
buttonc obc=new buttonc();
bc.addActionListener(obc);
buttoneq obeq=new buttoneq();
beq.addActionListener(obeq);
button0 ob0=new button0();
b0.addActionListener(ob0);
}
class button1 implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
t.setText("");
dis=t.getText();
t.setText(dis+"1");
}
}
class button2 implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
t.setText("");
dis=t.getText();
t.setText(dis+"2");
}
}
class button3 implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
t.setText("");
dis=t.getText();
t.setText(dis+"3");
}
}
class button4 implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
t.setText("");
dis=t.getText();
t.setText(dis+"4");
}
}
class button5 implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
t.setText("");
dis=t.getText();
t.setText(dis+"5");
}
}
class button6 implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
t.setText("");
dis=t.getText();
t.setText(dis+"6");
}
}
class button7 implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
t.setText("");
dis=t.getText();
t.setText(dis+"7");
}
}
class button8 implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
t.setText("");
dis=t.getText();
t.setText(dis+"8");
}
}
class button9 implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
t.setText("");
dis=t.getText();
t.setText(dis+"9");
}
}
class button0 implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
t.setText("");
dis=t.getText();
t.setText(dis+"0");
}
}
class buttonp implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
num1=Double.parseDouble(t.getText());
t.setText("+");
result='+';
}
}
class buttons implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
num1=Double.parseDouble(t.getText());
t.setText("-");
result='-';
}
}
class buttonm implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
num1=Double.parseDouble(t.getText());
t.setText("*");
result='*';
}
}
class buttond implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
num1=Double.parseDouble(t.getText());
t.setText("/");
result='/';
}
}
class buttoneq implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
num2=Double.parseDouble(t.getText());
if(result=='+')
{
num2=num1+num2;
t.setText(Double.toString(num2));
}
else if(result=='-')
{
num2=num1-num2;
t.setText(Double.toString(num2));
}
if(result=='*')
{
num2=num1*num2;
t.setText(Double.toString(num2));
}
if(result=='/')
{
num2=num1/num2;
t.setText(Double.toString(num2));
}
}
}
class buttonc implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
dis="";
num1=0;
num2=0;
t.setText("");
}
}
}
class GUI12
{
public static void main(String asd[])
{
abc obj=new abc();
}
}
import javax.swing.*;
import java.awt.*;
class gui
{
JFrame f;
JButton
b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,b21,b22,b23,b24,b25,b2
6,b27,b28,b29,b30,
b31,b32,b33,b34;
JTextField t,t1;
JPanel p,p1,p2;
void g()
{
f = new JFrame();
Container c = f.getContentPane();
c.setLayout(new BorderLayout());
t=new JTextField(30);
t1 = new JTextField(30);
b0=new JButton("0");
b1=new JButton("1");
b2=new JButton("2");b2.setBackground(Color.BLUE);
b3=new JButton("3");
b4=new JButton("4");
b5=new JButton("5");
b6=new JButton("6");
b7=new JButton("7");
b8=new JButton("8");
b9=new JButton("9");
b10=new JButton("10");
b11=new JButton("11");
b12=new JButton("12");
b13=new JButton("13");
b14=new JButton("14");
b15=new JButton("15");
b16=new JButton("16");
b17=new JButton("17");
b18=new JButton("18");
b19=new JButton("19");
b20=new JButton("20");
b21=new JButton("21");
b22=new JButton("22");
b23=new JButton("23");
b24=new JButton("24");
b25=new JButton("25");
b26=new JButton("26");
b27=new JButton("27");
b28=new JButton("28");
b29=new JButton("29");
b30=new JButton("30");
b31=new JButton("31");
b32=new JButton("32");
b33=new JButton("33");
b34=new JButton("34");
p = new JPanel(new GridLayout(5,1,5,5));
p.setBackground(Color.RED);
p1 = new JPanel(new GridLayout(8,3,5,5));
p1.setBackground(Color.BLUE);
p2 = new JPanel(new GridLayout(3,5,5,5));
p2.setBackground(Color.GREEN);
p.add(b0);
p.add(b1);
p.add(b2);
p.add(b3);
p.add(b4);
p1.add(b5);
p1.add(b6);
p1.add(b7);
p1.add(b8);
p1.add(b9);
p1.add(b10);
p1.add(b11);
p1.add(b12);
p1.add(b13);
p1.add(b14);
p1.add(b21);
p1.add(b15);
p1.add(b16);
p1.add(b17);
p1.add(b18);
p1.add(b19);
p1.add(b20);
p1.add(b21);
p2.add(b22);
p2.add(b23);
p2.add(b24);
p2.add(b25);
p2.add(b26);
p2.add(b27);
p2.add(b28);
p2.add(b29);
p2.add(b30);
p2.add(b31);
p2.add(b32);
p2.add(b33);
p2.add(b34);
p.add(t);
p.add(t1);
c.add(t1,BorderLayout.SOUTH);
c.add(t,BorderLayout.NORTH);
c.add(p,BorderLayout.EAST);
c.add(p1,BorderLayout.WEST);
c.add(p2,BorderLayout.CENTER);
f.setSize(400,400);
f.setVisible(true);
}
}
class GUI13
{
public static void main(String app[])
{
gui ob = new gui();
ob.g();
}
}
import javax.swing.*;
import java.awt.*;
class gui
{
JFrame f;
JButton b,b1,b2;
JTextField t,t1,t2,t3;
JPanel p,p1,p2,p3,p4;
void g()
{
f=new JFrame();
Container c = f.getContentPane();
c.setLayout(new BorderLayout());//Grid
b=new JButton("+");
b1=new JButton("-");
b2=new JButton("=");
t=new JTextField(30);
t1=new JTextField(30);
t2=new JTextField(30);
t3=new JTextField(30);
p=new JPanel(new GridLayout(1,1,5,5));
p.setBackground(Color.GREEN);
p1=new JPanel(new FlowLayout(500));
p2=new JPanel(new GridLayout());
p3=new JPanel(new GridLayout(1,1,5,5));
p4=new JPanel(new GridLayout(2,1,5,5));
p3.add(t3);
p.add(t);
p1.add(t1);
p2.add(t2);
p4.add(b);
p4.add(b1);
p4.add(b2);
c.add(t3, BorderLayout.NORTH);
c.add(t1, BorderLayout.WEST);
c.add(p4, BorderLayout.CENTER);
c.add(t2, BorderLayout.EAST);
c.add(t, BorderLayout.SOUTH);
f.setSize(400,400);
f.setVisible(true);
}
}
class GUI14
{
public static void main(String app[])
{
gui ob = new gui();
ob.g();
}
}
import javax.swing.*;
import java.awt.*;
class gui
{
JFrame f;
JTextField t,t1;
JButton b,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18;
JPanel p,p1;
void g()
{
Container c=f.getContentPane();//no space getContentPane
c.setLayout(new BorderLayout());//no space setLayout
t=new JTextField(10);
t1=new JTextField(5);
b=new JButton("0");
b1=new JButton("1");
b2=new JButton("2");
b3=new JButton("3");
b4=new JButton("4");
b5=new JButton("5");
b6=new JButton("6");
b7=new JButton("7");
b8=new JButton("8");
b9=new JButton("9");
b10=new JButton("10");
b11=new JButton("11");
b12=new JButton("12");
b13=new JButton("13");
b14=new JButton("14");
b15=new JButton("15");
b16=new JButton("16");
b17=new JButton("17");
b18=new JButton("18");
p=new JPanel(new GridLayout(1,1,2,2));
p1=new JPanel(new FlowLayout());
p.add(t);
p.add(t);
p1.add(b);
p1.add(b1);
p1.add(b2);
p1.add(b3);
p1.add(b4);
p1.add(b5);
p1.add(b6);
p1.add(b7);
p1.add(b8);
p1.add(b9);
p1.add(b10);
p1.add(b11);
p1.add(b12);
p1.add(b13);
p1.add(b14);
p1.add(b15);
p1.add(b16);
p1.add(b18);
c.add(p,BorderLayout.NORTH);
c.add(p1,BorderLayout.CENTER);
f.setSize(200,200);
f.setVisible(true);
}
}
class GUI15
{
public static void main(String app[])
{
gui ob = new gui();
ob.g();
}
}
import javax.swing.*;
import java.awt.*;
class gui
{
JFrame f;
JTextField t,t1;
JButton b,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15;
void g()
{
Container c=f.getContentPane();
c.setLayout(new GridLayout(4,4));
t = new JTextField(5);
t1 = new JTextField(5);
b = new JButton("0");
b1 = new JButton("1");
b2 = new JButton("2");
b3 = new JButton("3");
b4 = new JButton("4");
b5 = new JButton("5");
b6 = new JButton("6");
b7 = new JButton("7");
b8 = new JButton("8");
b9 = new JButton("9");
b10 = new JButton("/");
b11 = new JButton("+");
b12 = new JButton("-");
b13 = new JButton("*");
b14 = new JButton("=");
b15 = new JButton(".");
c.add(t);
c.add(t1);
c.add(b);
c.add(b1);
c.add(b2);
c.add(b3);
c.add(b4);
c.add(b5);
c.add(b6);
c.add(b7);
c.add(b8);
c.add(b9);
c.add(b10);
c.add(b11);
c.add(b12);
c.add(b13);
c.add(b14);
c.add(b15);
f.setSize(200,200);
f.setVisible(true);
}
}
class GUI16
{
public static void main(String app[]) //missing method body or declare abstract
{
gui ob = new gui();
ob.g();
}
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class abc
{
JFrame f;
JButton b;
void cal()
{
f=new JFrame();
Container c=f.getContentPane();
c.setLayout(new FlowLayout());
b=new JButton("Hello");
c.add(b);
f.setSize(200,200);
f.setVisible(true);
f.setResizable(false);
clsb ob=new clsb();
b.addActionListener(ob);
}
class clsb implements ActionListener
{
public void actionPerformed(ActionEvent a)
{
JOptionPane.showMessageDialog(null,"Hello is processing");
}
}
}
class GUI17
{
public static void main(String asd[])
{
abc ob=new abc();
ob.cal();
}
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class gui
{
int i;
String n;
JFrame f;
JButton b;
JButton b1;
JTextField t;
void g()
{
f = new JFrame();
Container c = f.getContentPane();
c.setLayout(new FlowLayout());
b = new JButton("B");
b1 = new JButton("B1");
t = new JTextField(50);
c.add(t);
c.add(b);
c.add(b1);
f.setSize(200,200);
f.setVisible(true);
button ob = new button();//no words of "class" will be used 9mistakes
b.addActionListener(ob);
button1 ob1 = new button1();
b1.addActionListener(ob1);
}
class button implements ActionListener//mis ();
{
public void actionPerformed(ActionEvent a)//mis ;
{
t.setText("");
n=t.getText();
t.setText(n+"Hello");
}
}
class button1 implements ActionListener//no ();
{
public void actionPerformed(ActionEvent a)//mis ;
{
t.setText("");
n=t.getText();
for(i=0;i<5;i=i++)
{
t.setText(n+"G");
t.setText(i+"READ THIS");
JOptionPane.showMessageDialog(null,"TERI PAN DE");
JOptionPane.showMessageDialog(null,"BEGARAT, SALA");
JOptionPane.showMessageDialog(null,"PCS");
}
}
}
}
class GUI18
{
public static void main(String app[]) //mis ;
{
gui obj = new gui();
obj.g();
}
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class gui
{
String s;
JFrame f;
JButton
bc,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10;
JTextField t;
void g() //MIS;
{
f = new JFrame();
Container c = f.getContentPane();
c.setLayout(new GridLayout(3,3,5,5));
bc=new JButton("C");
b0=new JButton("0");
b1=new JButton("1");
b2=new JButton("2");
b3=new JButton("3");
b4=new JButton("4");
b5=new JButton("5");
b6=new JButton("6");
b7=new JButton("7");
b8=new JButton("8");
b9=new JButton("9");
b10=new JButton("10");
t=new JTextField(20);
c.add(t);
c.add(bc);
c.add(b0);
c.add(b1);
c.add(b2);
c.add(b3);
c.add(b4);
c.add(b5);
c.add(b6);
c.add(b7);
c.add(b8);
c.add(b9);
c.add(b10);
f.setSize(200,200);
f.setVisible(true);
button0 ob00 = new button0();
b0.addActionListener(ob00);
button1 ob1 = new button1();
b1.addActionListener(ob1);
button2 ob2 = new button2();
b2.addActionListener(ob2);
button3 ob3 = new button3();
b3.addActionListener(ob3);
button4 ob4 = new button4();
b4.addActionListener(ob4);
button5 ob5 = new button5();
b5.addActionListener(ob5);
button6 ob6 = new button6();
b6.addActionListener(ob6);
button7 ob7 = new button7();
b7.addActionListener(ob7);
button8 ob8 = new button8();
b8.addActionListener(ob8);
button9 ob9 = new button9();
b9.addActionListener(ob9);
button10 ob10 = new button10();
b10.addActionListener(ob10);
button0 ob0 = new button0();
b0.addActionListener(ob0);
buttonc obc = new buttonc();
bc.addActionListener(obc);
}
//FOR "0"
class button0 implements ActionListener
{
public void actionPerformed(ActionEvent a)
{
t.setText("0");
s = t.getText();
t.setText(s+"0");
}
}
// FOR "1"
class button1 implements ActionListener
{
public void actionPerformed(ActionEvent a)
{
t.setText("");
s=t.getText();
t.setText(s+"1");
}
}
//FOR "2"
class button2 implements ActionListener
{
public void actionPerformed(ActionEvent a)
{
t.setText("");
s=t.getText();
t.setText(s+"2");
}
}
//FOR "3"
class button3 implements ActionListener
{
public void actionPerformed(ActionEvent a)
{
t.setText("");
s=t.getText();
t.setText(s+"3");
}
}
//FOR "4"
class button4 implements ActionListener
{
public void actionPerformed(ActionEvent a)
{
t.setText("");
s=t.getText();
t.setText(s+"4");
}
}
//FOR "5"
class button5 implements ActionListener
{
public void actionPerformed(ActionEvent a)
{
t.setText("");
s=t.getText();
t.setText(s+"5");
}
}
//FOR "6"
class button6 implements ActionListener
{
public void actionPerformed(ActionEvent a)
{
t.setText("");
s=t.getText();
t.setText(s+"6");
}
}
//FOR "7"
class button7 implements ActionListener
{
public void actionPerformed(ActionEvent a)
{
t.setText("");
s=t.getText();
t.setText(s+"7");
}
}
//FOR "8"
class button8 implements ActionListener
{
public void actionPerformed(ActionEvent a)
{
t.setText("");
s=t.getText();
t.setText(s+"8");
}
}
// FOR "9"
class button9 implements ActionListener
{
public void actionPerformed(ActionEvent a)
{
t.setText("");
s=t.getText();
t.setText(s+"9");
}
}
// FOR "10"
class button10 implements ActionListener
{
public void actionPerformed(ActionEvent a)
{
t.setText("");
s=t.getText();
t.setText(s+"10");
}
}
// FOR "CLEAR"
class buttonc implements ActionListener
{
public void actionPerformed(ActionEvent a)
{
t.setText("");
s=t.getText();
t.setText(s+" ");
}
}
}
class GUI19
{
public static void main(String app[])
{
gui obj = new gui();
obj.g();
}
}
class pa
{
int a;
int b;
void show()
{
System.out.println("value of a = " + a);
System.out.println("value of b = " + b);
}
}
class ch extends pa
{
}
class in0
{
public static void main(String app[])
{
pa ob = new pa(); //(;) semicolon laganay hein
ob.a = 2; //other wise it will show (file not find)
ob.b = 3;
ob.show();
ch ob1 = new ch();
ob1.a = 4;
ob1.b = 5;
ob1.show();
}
}
class pa
{
int a;
int b;
int s;
int p;
void show()
{
System.out.println("value of a = " + a);
System.out.println("value of b = " + b);
s = a + b;
System.out.println("value of sum = " + s);
}
}
class chi extends pa
{
void mul()
{
p = a*b;
System.out.println("multi is :" + p);
}
}
class in1
{
public static void main(String app[])
{
pa ob = new pa();
ob.a = 2;
ob.b = 3;
ob.show();
chi ob1 = new chi();
ob1.a = 4;
ob1.b = 5;
ob1.show();
ob1.mul();
}
}
class pa
{
int a;
int b;
void show()
{
System.out.println("value of a = " + a);
System.out.println("value of b = " + b);
}
}
class ch extends pa
{
}
class inh
{
public static void main(String app[])
{
pa ob = new pa(); //(;) semicolon laganay hein
pa.a = 2; //other wise it will show (file not find)
pa.b = 3;
pa.show();
ch ob1 = new ch();
ob1.a = 4;
ob1.b = 5;
ob1.show();
}
}
class parant
{
int a;
int b;
int c;
void set()
{
System.out.println("value of a is = " + a);
System.out.println("value of b is = " + b);
System.out.println("value of c is = " + c);
}
int math() // ; will show miss method body
{
return a+b+c;
}
class child extends parant
{
}
}
class inh0
{
public static void main(String opps[])
{
parant ob = new parant();
parant ob1 = new parant();
ob.a = 2;
ob.b = 3;
ob.c = 4;
ob.set();
int e = ob.math();
System.out.println("
ob1.a = 5;
ob1.b = 6;
ob1.c = 7;
ob1.set();
ob1.math();
}
}
import javax.swing.*;
class inplus
{
public static void main(String app[])
{
int a;
int b;
int c;
int d;
int s;
String in;
in = JOptionPane.showInputDialog("Enter a=");
a = Integer.parseInt(in);
in = JOptionPane.showInputDialog("Enter b=");
b = Integer.parseInt(in);
in = JOptionPane.showInputDialog("Enter c=");
c = Integer.parseInt(in);
in = JOptionPane.showInputDialog("Enter d=");
d = Integer.parseInt(in);
s = a + b + c + d;
System.out.println("Sum of no is =" + s);
}
}
import javax.swing.*;
class input
{
public static void main(String app[])
{
int a;
int b;
int c;
String in;
in = JOptionPane.showInputDialog("Enter 1st no=");
a = Integer.parseInt(in);
in = JOptionPane.showInputDialog("Enter 2nd no=");
b = Integer.parseInt(in);
c = a * b;
System.out.println("Multiplication is =" + c);
}
}
public interface person
{
void speak();
}
class teacher implements person // implement spellings
{
void speak()
{
System.out.println("Teacher");
}
}
class interface00
{
public static void main(String args[])
{
person p;
p = new person();
p.speak();
}
}
class A
{
int a;
int b;
void show()
{
System.out.println( a + b);
}
}
class B extends A
{
int c;
void showc()
{
System.out.println("c" + c);
}
}
class m
{
public static void main(String args[])
{
A ob1 = new A();
ob1.a = 5;
ob1.b = 6;
ob1.show();
B ob2 = new B();
ob2.a = 3;
ob2.b = 2;
ob2.c = 1;
ob2.show();
ob2.showc();
}
}
class box
{
double w;
double h;
double d;
double v;
void volume()
{
v = w*h*d;
System.out.println("Volume is:");
System.out.println(+ v);
}
}
class m0000
{
public static void main(String args[])
{
box mybox = new box();
box mybox1 = new box();
mybox.w = 10;
mybox.h = 7;
mybox.d = 5;
mybox1.h = 3;
mybox1.w = 4;
mybox1.d = 6;
mybox.volume();
mybox1.volume();
}
}
class box
{
int h;
int b;
int area()
{
return h*b;
}
int perimeter()
{
return 2*b+h;
}
}
class m000
{
public static void main(String app[])
{
box b1 = new box();
b1.h = 2;
b1.b = 3;
int a = b1.area();
box b2 = new box();
b2.h = 5;
b2.b = 2;
int c = b2.perimeter();
System.out.println("Area of box 1 = " + a);
System.out.println("Perimeter of box 2 = " + c);
}
}
class circle
{
int r;
void set()
{
System.out.println("R is = " + r);
}
double Calcarea()
{
return 3.14*r*r;
}
double Calccircum()
{
return 2*3.14*r;
}
}
class m00
{
public static void main(String app[])
{
circle ob1 = new circle();
circle ob2 = new circle();
ob1.r = 2;
ob2.r = 3;
ob1.set();
ob2.set();
double f = ob1.Calcarea();
double g = ob1.Calccircum();
System.out.println("Area of ob1 is = " + f);
System.out.println("circumference of ob1 is = " + g);
double d = ob2.Calcarea();
double e = ob2.Calccircum();
System.out.println("Area of ob2 is = " + d);
System.out.println("circumference of ob2 is = " + e);
System.out.println("new is = " + (e * 4));
}
}
class wq
{
double l;
double h;
double a;
double p;
void area()
{
a = l * h;
System.out.println("The area is:" + a);
}
void perimeter()
{
p = 2*l + 2*h;
System.out.println("Perimeter is:" + p);
}
}
class m0
{
public static void main(String args[])
{
wq obj = new wq();
obj.l = 10;
obj.h = 5;
obj.area();
obj.perimeter();
}
}
class object
{
int a,b,c;
void set()
{
a = 0;
b = 0;
c = 0;
}
int sum()
{
return a+b+c;
}
float avg()
{
return (a+b+c)/3;
}
}
class m1
{
public static void main(String app[])
{
object ob = new object();
object ob1 = new object();
object ob2 = new object();
object ob3 = new object();
ob.a = 5;
ob.b = 3;
ob.c = 4;
ob1.a = 5;
ob1.b = 6;
ob1.c = 7;
ob2.a = 1;
ob2.b = 2;
ob2.c = 3;
ob3.a = 4;
ob3.b = 5;
ob3.c = 6;
int s = ob.sum();
float z = ob.avg();
int t = ob1.sum();
int q = ob2.sum();
float r = ob3.avg();
System.out.println("Sum is = " + s);
System.out.println("Average is = " + z);
System.out.println("Sum of 2 is = " + t);
System.out.println("Sum of ob2 is =" + q);
System.out.println("Avg of ob3 is = " + r);
}
}
class object
{
int p,q;
void set()
{
p = q = 5;
}
void show()
{
System.out.println("Value of P is = " + p);
System.out.println("Value of Q is = " + q);
}
int sum()
{
return p+q;
}
}
class m3
{
public static void main(String app[])
{
object ob1 = new object();
ob1.p = 3;
ob1.q = 4;
ob1.show();
int a = ob1.sum();
System.out.println("Sum is = " + a);
}
}
class object
{
int a,b,c;
void set()
{
a = b = c = 0;
}
void show()
{
System.out.println("Value of a = " + a);
System.out.println("Value of b = " + b);
System.out.println("Value of c = " + c);
}
int sum()
{
return a+b+c;
}
int sub()
{
return a+b-c;
}
float div()
{
return (a+c)/b;
}
}
class m4
{
public static void main(String mango[])
{
object ob1 = new object();
object ob2 = new object();
object ob3 = new object();
ob1.a = 1;
ob1.b = 2;
ob1.c = 3;
ob2.a = 4;
ob2.b = 5;
ob2.c = 6;
ob3.a = 7;
ob3.b = 8;
ob3.c = 9;
ob1.show();
ob2.show();
ob3.show();
int d = ob1.sum();
int e = ob1.sub();
float f = ob1.div();
int g = ob2.sum();
int h = ob2.sub();
float i = ob2.div();
int j = ob3.sum();
int k = ob3.sub();
float l = ob3.div();
System.out.println("Sum of object 1 is = " + d);
System.out.println("Subtraction of object 1 is = " + e);
System.out.println("Division of object 1 is = " + f);
System.out.println("Sum of object 2 is = " + g);
System.out.println("Subtraction of object 2 is = " + h);
System.out.println("Division of object 2 is = " + i);
System.out.println("Sum of object 3 is = " + j);
System.out.println("Subtraction of object 3 is = " + k);
System.out.println("Division of object 3 is = " + l);
}
}
class object
{
double name,team;
String a,b;
void input()
{
a = "orange";
b = "mango";
}
void show()
{
a = "ABC";
b = "Super A+";
}
}
class m5
{
public static void main(String app[])
{
object pla = new object();
pla.input();
pla.show();
System.out.println("Player name is =" + pla.a);
}
}
class object
{
int height;
int width;
}
class m6
{
public static void main(String app[])
{
object ob1 = new object();
object ob2 = new object();
ob1.height = 2;
ob1.width = 3;
ob2.heigth = 4;
ob2.width = 5;
int a = (ob1.heigth)*(ob1.width);
int b = (ob2.heigth)*(ob2.width);
System.out.println("Object No 1 is = " + a);
System.out.println("Object No 2 is = " + b);
}
}
class object
{
int width;
int height;
int depth;
void vol()
{
System.out.prontln("volume is = ") ;
System.out.prontln(width* height *depth);
}
}
class m7
{
public static void main(String app[])
{
object ob1 = new object();
object ob2 = new object();
ob1.width = 2;
ob1.height = 3;
ob1.depth = 4;
ob2.width = 5;
ob2.height = 6;
ob2.depth = 7;
ob1.vol();
ob2.vol();
}
}
//pass by object
class object
{
int a;
int b;
void pbo(object p) //Creating an object of class type
{
p.a = p.a + 2;
p.b = p.b +3;
}
}
class m8
{
public static void main(String app[])
{
object ob1 = new object();
ob1.a = 2;
ob1.b = 3;
System.out.println("before calling value of ob1.a = " + ob1.a);
System.out.println("before calling value of ob1.b = " + ob1.b);
ob1.pbo(ob1);
/* p will be replaced by ob1
in method pbo*/
System.out.println("After calling value of ob1.a = "+ ob1.a);
System.out.println("After calling value of ob1.b = " + ob1.b);
}
}
// pass by value
class object
{
void pbv(int a, int b) // method with parameter in ()
{
a = a * 2;
b = b * 3; // Only formal parameter's value will be change
}
}
class m9
{
public static void main(String app[])
{
object ob1 = new object();
int c;
int d;
c = 4;
d = 5;
ob1.pbv(c,d);
/* calling the function pbv
and assigning the value of c, d to a, b */
System.out.println("value of c = " + c);
System.out.println("value of d = " + d);
}
}
class object
{
String name;
int roll;
char sex;
void set()
{
name = "Ali" ;
roll = 1 ;
sex = 'M';
}
void show() //No semicolon
{
System.out.println("Name is = " + name);
System.out.println("Roll No is = " + roll);
System.out.println("Sex is = " + sex);
}
}
class m10
{
public static void main (String app[])
{
object a = new object();
a.name = "ali"; // '' will replace ""
a.roll = 2; // write as it is instead of a.int roll = 2;
a.sex = 'M'; //"" will be replace with ''
a.show();
a.set();
a.show();
}
}
class object
{
int a;
int b;
int c;
void val()
{
System.out.println(" Values are = " + a + " and " + b );
}
void sum()
{
System.out.println(" result is= " + (a + b) );
}
int cal()
{
return a * b;
}
}
class m11
{
public static void main(String app[])
{
object ob = new object();
ob.a = 2;
ob.b = 3;
ob.val();
ob.a = 4;
ob.b = 5;
ob.sum();
ob.val();
int d = ob.cal();
System.out.println(" result is= " + d);
System.out.println(" result is= " + (ob.a + ob.b) );
}
}
class object
{
int a;
int b;
void pbo(object p)
{
p.a = p.a+2;
p.b = p.b+3;
}
}
class m12
{
public static void main(String app[])
{
object ob = new object();
ob.a = 4;
ob.b = 5;
System.out.println("Value of ob.a" + ob.a);
ob.pbo(ob);
System.out.println("Value of ob.a" + ob.a);
}
}
// pass by value
class object
{
void pbv(int a, int b)
{
a = a + 2;
System.out.println("Value of a is = " + a);
b = b + 3;
System.out.println("Value of b is = " + b);
}
}
class m13
{
public static void main (String app[])
{
object ob = new object();
int c = 4;
int d = 5;
ob.pbv(c,d);
System.out.println("Value of c is = " + c);
System.out.println("Value of d is = " + d);
}
}
// pass by value
class abc
{
void pbv(int a, int b, int c)
{
a = a + b + c;
System.out.println("Value of a is = " + a);
b = b + a;
System.out.println("Value of b is = " + b);
c = c + 2;
System.out.println("Value of c is = " + c);
System.out.println(" ");
}
}
class m14
{
public static void main (String app[])
{
abc ob = new abc();
int c = 3;
int d = 4;
int e = 5;
ob.pbv(c,d,e);
System.out.println(" ");
System.out.println("Actual Value of c is = " + c);
System.out.println("Actual Value of d is = " + d);
System.out.println("Actual Value of e is = " + e);
}
}
// pass by reference
class obj
{
int a;
int b;
void pbo( obj p)
{
p.a = a + 2;
p.b = b + 3;
}
}
class m15
{
public static void main (String app[])
{
obj ob = new obj();
ob.a = 4;
ob.b = 5;
// Before calling function
System.out.println("Value before call " + ob.a);
System.out.println("Value before call " + ob.b);
System.out.println(" ");
ob.pbo(ob);
System.out.println("Value after call " + ob.a);
System.out.println("Value after call " + ob.b);
}
}
// Acccess
class obj
{
int a;
int b;
private int c;
private void show()
{
System.out.println("Value of a is " + a);
System.out.println("Value of b is " + b);
System.out.println("Value of c is " + c);
}
void set(int p)
{
c = p;
}
void acc()
{
show();
}
}
class m16
{
public static void main (String app[])
{
obj ob = new obj();
ob.a = 2;
ob.b = 3;
ob.set(4);
ob.acc();
}
}
class abc
{
int a;
int b;
int c;
void set()
{
a = b = 0;
}
int set1(int p,int q)
{
a = p;
b = q;
int s;
s = a * b;
return s;
}
void multi()
//void multi()
{
c = a * b;
//c = a * b;
System.out.println("Multiplication is:" + c);
// System.out.println("Multiplication is:" + c);
}
}
class ma
{
public static void main(String args[])
{
//int ab;
abc obj = new abc(intp 4,intq5);
// obj.a = 10;
//obj.b = 10;
int d = obj.set1();
/* obj.multi();
ab=obj.set1(2,3);*/
System.out.println("Set1 is " + d); //System.out.println("Set1 is "+ ab);
}
}
import java.awt.*;
import javax.swing.*;
clas abc
{
JButton b;
JTextField t;
JFrame f;
void creat()
{
f = new JFrame("Shahzad;s Calculatetr");
Container c = f.getContentPane();
c.setLayout(new FlowLayout());
t = new JTextField(20);
b = new JButton("Pagal");
c.add(t);
C.add(b);
f.setSize(400,400);
F.setVisible(true);
}
}
clas main
{
public static void main(String args[])
{
abc obj = new abc();
obj.creat();
}
}
class wq
{
double l;
double h;
void area()
{
System.out.println("The area is:" + (l * h));
}
void perimeter()
{
System.out.println("Perimeter is:" + (2*l + 2*h));
}
double summ()
{
return l*h+h;
}
}
class main1
{
public static void main(String args[])
{
wq obj = new wq();
obj.l = 10;
obj.h = 5;
obj.area();
obj.perimeter();
double d = obj.summ();
System.out.println("Sum is = " + d);
}
}
import javax.swing.*;
class math
{
public static void main(String args[])
{
int a;
int c;
c = 1;
String in;
in = JOptionPane.showInputDialog("Enter the number:");
a = Integer.parseInt(in);
while(c<=10)
{
System.out.println(a + "*" + c + "=" + a*c);
c = c + 1;
}
}
}
class obje
{
int no1;
int no2;
obje(int n1, int n2)
{
no1 = n1;
no2 = n2;
System.out.println("value of 1st is = " + n1 + " " + n2);
}
obje(int n1)
{
System.out.println("value of 1st is = " + n1);
}
}
class ovecon
{
public static void main(String app[])
{
obje ob = new obje(2,3);
obje ob1 = new obje(4); // ob(object should be different
}
}
class obj
{
int a;
int b;
obj(int c, int d)
{
a = c;
b = d;
System.out.println("Value of c and d is = " + c + " " + d);
}
obj(int c)
{
System.out.println("Value of c is = " + c);
}
obj(int c, int d, int e)
{
System.out.println("Value of c, d and e is = " + c + " " + d + " " + e);
}
}
class ovecon1
{
public static void main(String app[])
{
obj ob1 = new obj(4);
obj ob = new obj(2,3);
obj ob2 = new obj(5,6,7);
}
}
class A
{
void show()
{
System.out.println("A");
}
}
class B extends A
{
void show()
{
System.out.println("B");
}
}
class C extends B
{
void show()
{
System.out.println("C");
}
}
class over
{
public static void main(String args[])
{
A r;
r = new A();
r.show();
r = new B();
r.show();
r = new C();
r.show();
}
}
class math
{
int a=10;
int b=20;
void call() // Duplicate method in every class
{
System.out.println("a , b is = " + a + " " + b);
}
}
class plus extends math
{
void call()
{
System.out.println("a + b is = " + (a + b));
}
}
class minus extends plus
{
void call()
{
System.out.println("a - b is = " + (a - b) );
}
}
class mul extends minus
{
void call()
{
System.out.println("a * b is = " + ( a * b));
}
}
class div extends mul
{
void call()
{
System.out.println("a / b is = " + (a / b));
}
}
class over1
{
public static void main(String args[])
{
math m;
m = new math();
m.call();
m = new plus();
m.call();
m = new minus();
m.call();
m = new mul();
m.call();
m = new div();
m.call();
}
}
iyyymport javax.swing.*;
class math
{
static a,b;
String s;
s=JOptionPane.showInputDialog("Enter a");
a=Integer.parseInt(s);
s=JOptionPane.showInputDialog("Enter b");
b=Integer.parseInt(s);
void cal()
{
System.out.println("A and B is = " + a + " " + b);
}
}
class plus extends math
{
void cal()
{
System.out.println("A and B is = " + (a + b));
}
}
class minus extends plus
{
void cal()
{
System.out.println("A and B is = " + (a - b));
}
}
class mul extends minus
{
void cal()
{
System.out.println("A and B is = " + (a * b));
}
}
class div extends mul
{
void cal()
{
System.out.println("A and B is = " + (a / b));
}
}
class over2
{
public static void main(String args[])
{
math r;
r = new math();
r.cal();
}
}
class A
{
void test(int a)
{
System.out.println("Value of a is = " + a);
}
void test(int a, int b)
{
System.out.println("Value of a and b is = " + a +" ," + b);
}
void test(int a, int b, int c)
{
System.out.println("Value of a, b ,c is = " + a + " , " + b +" , " + c );
}
}
class ovmeth
{
public static void main(String app[])
{
A ob = new A();// new or A mai space honi hai
ob.test(5, 6, 7);
ob.test(2);
ob.test(3, 4);
}
}
class obj
{
void meth()
{
System.out.println("No value ");
}
void meth(int a)
{
System.out.println("Value of a is = " + a);
}
void meth(int a, int b)
{
System.out.println("Value of a and b is = " + a + " " + b);
}
void meth(int a, int b, int c)
{
System.out.println("Value of a , b and c is = " + a + " " + b + " " + c);
}
}
class ovmeth1
{
public static void main(String app[])
{
obj ob = new obj();
ob.meth();
ob.meth(1);
ob.meth(2,3);
ob.meth(4,5,6);
}
}
class pa
{
int a;
int b;
int m;
void show()
{
int s;
s = a + b;
System.out.println("Sum is :" + s);
}
}
class child extends pa
{
void show()
{
m = a * b;
System.out.println("multiple is :" + m);
}
}
class parent
{
public static void main(String args[])
{
pa obj = new pa();
obj.a = 5;
obj.b = 5;
obj.show();
child obj1 = new child();
obj1.a = 4;
obj1.b = 4;
obj1.show();
}
}
import javax.swing.*;
class q
{
public static void main(String args[])
{
int a;
int b;
int s;
String in;
in = JOptionPane.showInputDialog("Enter the number 1:");
a = Integer.parseInt(in);
in = JOptionPane.showInputDialog("Enter the number 2:");
b = Integer.parseInt(in);
s = a / b;
System.out.println("sum is:" + s);
}
}
import javax.swing.*;
class qw
{
public static void main(String args[])
{
int num;
String in;
in = JOptionPane.showInputDialog("Enter the number:");
num = Integer.parseInt(in);
if(num>=85)
System.out.println("Your grade is A+");
else if(num<=80 && num>75)
System.out.println("Yoyr grade is A");
else if(num<=70 && num>65)
System.out.println("Your grade is B");
else
System.out.println("Your are fail congrats");
}
}
class f
{
int fact(int n)
{
if (n==1)
{
return 1 ;
}
else
{
return n*fact(n-1);
}
}
}
class rec
{
public static void main(String app[])
{
f a = new f();
int r = a.fact(3);
System.out.println(r);
}
}
// recursion java program
class java
{
// here starts a function
int mul(int n)
{
if (n ==1)
{
return 1; // Body of method
}
else
{
return n*mul(n-1);
}
}
}
class rec1
{
public static void main (String app[])
{
java f = new java(); // creating a new object naming f
int a; // declare a variable a to store value of calling function
a = f.mul(3);
System.out.println("Factorial of no is = " + a);
}
}
class object
{
int fact(int n) // semicolon nhi lagna warna return mai error
{
if (n==10)
{
return 1;
}
else
{
return n+fact(n+1);
}
}
}
class rec2
{
public static void main(String app[])
{
object f = new object();
int a = f.fact(1);
System.out.println("Value of a is = " + a );
}
}
class obj
{
int fact(int n)
{
if(n==1)
{
return 1;
}
else
{
return n*fact(n-1);
}
}
}
class rec3
{
public static void main(String app[])
{
obj ob = new obj();
int c = ob.fact(4);
System.out.println("Value of C is = " + c);
}
}
class obj
{
int a;
int fact( int n)
{
if(n == 0)
{
return 1;
}
else
{
return a*a;
n-1;
}
}
}
class rec4
{
public static void main(String app[])
{
obj ob = new obj();
ob.a = 2;
int c = ob.fact(4);
System.out.println("Value of c ic = " + c);
}
}
class obj
{
int fact(int n) // no ;
{
if(n==1)
{
return 1;
}
else
{
return (n-1)*fact(n-1);
}
}
}
class rec5
{
public static void main(String app[])
{
obj ob = new obj();
int a = ob.fact(4);
System.out.println(" pow is = " + a);
}
}
class abc
{
int a;
int b;
double show()
{
int s;
s = a + b;
return s;
}
}
class ret
{
public static void main(String args[])
{
abc obj = new abc();
obj.a = 5;
obj.b = 5;
System.out.println(obj.show());
}
}
class math
{
void show()
{
int a = 10;
int b = 10;
System.out.println("A and b:"+ a + " " + b);
}
}
class plus extends math
{
void show()
{
s = a + b;
System.out.println("A + B"+ s);
}
}
class minus extends plus
{
void show()
{
int m;
m = a - b;
System.out.println("minus is:" + m);
}
}
class shahzad
{
public static void main(String args[])
{
math j;
j = new math();
j = new plus();
}
}
import javax.swing.*;
class simif
{
public static void main(String app[])
{
int n;
String o;
o = JOptionPane.showInputDialog("Enter n=");
n = Integer.parseInt(o);
if(n % 2 == 0)
System.out.println("NO is even" + n);
else
System.out.println("NO is odd" + n);
}
}
import javax.swing.*;
class simint2
{
public static void main(String app[])
{
int a,b,s;
String in;
in = JOptionPane.showInputDialog("Enter a");
a = Integer.parseInt(in);
in = JOptionPane.showInputDialog("Enter b");
b = Integer.parseInt(in);
s = a + b;
System.out.println("Sum is = " + s);
}
}
import javax.swing.*;
class simmul3
{
public static void main(String app[])
{
int a,b,s;
String n;
n = JOptionPane.showInputDialog("Enter a");
a = Integer.parseInt(n);
n = JOptionPane.showInputDialog("Enter b");
b = Integer.parseInt(n);
s = a * b;
System.out.println("Product is =" + s);
}
}
import javax.swing.*;
class simmul3
{
public static void main(String app[])
{
int a,b,s;
String n;
n = JOptionPane.showInputDialog("Enter a");
a = Integer.parseInt(n);
n = JOptionPane.showInputDialog("Enter b");
b = Integer.parseInt(n);
s = a * b;
System.out.println("Product is =" + s);
}
}
import javax.swing.*;
class simmul4
{
public static void main (String args[])
{
String n; // Capital S
int a,b,c,s;
n = JOptionPane.showInputDialog("Enter a = ");
a = Integer.parseInt(n);
n = JOptionPane.showInputDialog("Enter b = "); // Capital P
b = Integer.parseInt(n);
n = JOptionPane.showInputDialog("Enter c = ");
c = Integer.parseInt(n);
s = (a * b * c);
JOptionPane.showMessageDialog(null, " Product is = " + s);
System.out.println(" Product is = " + s);
}
}
import javax.swing.*;
class simodev4
{
public static void main(String app[])
{
int n;
String o;
o = JOptionPane.showInputDialog("Enter n=");
n = Integer.parseInt(o);
if(n % 2 == 0)
System.out.println("NO is even" + n);
else
System.out.println("NO is odd" + n);
}
}
import java.awt.*;
import java.applet.Applet;
public class simpleApplet extends jApplet
{
public void paint(Graphics g)
{
g.drawString("A Simple Applet" , 20, 20);
}
}
class object
{
static int a;
static int b;
static
{
a = 4;
b = 6;
}
static void show()
{
return "a = "+ a+ " " "b = "+ b ;
System.out.println("Value of a is = " + a);
System.out.println("Value of b is = " + b);
}
}
class stat
{
public static void main(String app[])
{
show();
}
}
class stat1
{
static int a;
static int b;
static
{
a = 4;
b = 6;
}
static void show()
{
System.out.println("Value of a is = " + a);
System.out.println("Value of b is = " + b);
}
static void sum()
{
System.out.println("Sum of no is = " + (a + b));
}
public static void main(String app[])
{
show();
sum();
}
}
class static
{
static int a;
static int b;
static
{
a = 4;
b = 6;
}
static void show()
{
System.out.println("Value of a is = " + a);
System.out.println("Value of b is = " + b);
}
public static void main(String app[])
{
show();
}
}

Java programs

  • 1.
    class AB { public staticvoid main(String args[]) { int a = 5; int b = 2; int p; int r; r = a * b; p = a ++ b; System.out.println(" result is= " + r); System.out.println(" result is= " + p ); System.out.println(" result is= " + (a - b) ); } } class AB12 { public static void main(String args[]) { int a = 5; int b = 2; int p; int r; r = a * b; p = a + b; System.out.println(" result is= " + r); System.out.println(" result is= " + p ); System.out.println(" result is= " + (a - b) ); } } import javax.swing.*; abstract class person { abstract void speak(); } class tea extends person { void speak() { JOptionPane.showMessageDialog(null, " Teacher"); System.out.println("Teacher"); }
  • 2.
    } class st extendsperson { void speak() { JOptionPane.showMessageDialog(null, "Student"); System.out.println("Student"); } } class doc extends person { void speak() { JOptionPane.showMessageDialog(null, " Doctor"); System.out.println("Doctor"); } } class abst00 { public static void main(String app[]) { person r; r = new tea(); r.speak(); r = new st(); r.speak(); r = new doc(); r.speak(); } } class A { private int a; int b; void set(int p) { a = p; } void show() { System.out.println("a ,b , is = " +" " + a ); System.out.println("a ,b , is = " +" " + b ); }
  • 3.
    } class Acc { public staticvoid main (String app[]) { A ob = new A(); ob.b = 6; ob.set(6); ob.show(); // without show programm will not run } } class object { public int a; public int b; private int c; void show() { System.out.println("a is = " + a); System.out.println("b is = " + b); System.out.println("c is = " + c); } void set(int p) { c = p; } } class ACC0 { public static void main(String app[]) { object ob = new object(); ob.a = 2; ob.b = 3; //sob.c = 5; will produce error ob.set(4); ob.show(); } } class object { private int a;
  • 4.
    int b; void show() { System.out.println("AIS = " + a); System.out.println("B IS = " + b); } void set(int p) { a= p ; } } class acc1 { public static void main(String app[]) { object ob = new object(); ob.b = 7;// if ob.show is 1st then error = A is = 0, B is = 7 ob.set(77); ob.show(); } } class A { int a; int b; private void show() { System.out.println(" Value of A and B is = " + a + " , " + b); } void callshow() { show(); } } class acc2 { public static void main(String app[]) { A ob = new A(); ob.a = 2; ob.b = 3; ob. callshow();// call or show k darmian space nhi honi hai }
  • 5.
    } class A { int a; intb; private int c; private void show() { System.out.println("Value of A, B, C is = " + a + " , " + b + " , " + c); } void c(int p) { c = p; } void callshow() { show(); } } class acc3 { public static void main(String app[]) { A ob = new A(); ob.a = 2; ob.b = 3; ob.c(4); ob.callshow(); } } class acce { int a; int b; private int c; void show() { System.out.println(" Value of a = " + a ); System.out.println(" Value of b = " + b ); System.out.println(" Value of c = " + c ); } void set(int p) // space b/w int and p
  • 6.
    { c = p; } privatevoid sum() // void is necessory { System.out.println(" Sum of a,b,c is = " + ( a + b + c ) ); } void meth() { sum();// comass are necessory } } class acc4 { public static void main(String app[]) { acce ob = new acce(); ob.a = 2; ob.b = 3; ob.set(4); ob.show(); ob.meth(); } } import java.awt.Graphics; import java.awt.Font; import java.awt.Color; public class App extends Applet { Font f = new Font("TimesRoman",Font.BOLD,36); public void paint(Graphics g) { g.setFont(f); g.setColor(Color.red); g.drawString("Hello again", 5, 50); } } import java.awt.*; import java.applet.*; public class Applet1 extends Applet { public void paint(graphics g)
  • 7.
    { g.drawString("A Simple Applet", 20, 20); } } import javax.swing.*; class az { public static void main(String args[]) { int a; String in; in = JOptionPane.showInputDialog("Enter the number"); a = Integer.parseInt(in); if(a%2==0) System.out.println("The square is :" + a * a); } } class math { int a,b; void cal() { String in; in=JOptionPane.showInputDialog("Enter a="); a=Integer.pasreInt(in); in=JOptionPane.showInputDialog("Enter b="); b=Integer.parseInt(in); } } class add extends math { void cal() { JOptionPane.showMessageDialog("sum="+(a+b)); } } class minus extends add { void cal{ JOptionPane.showMessageDialog("minus="+(a-b)); } }
  • 8.
    class multiply extendsminus { void cal{ JOptionPane.showMessageDialog("multipl="+(a*b)) } class cr { public static void main(String args[]) { math ob=new math(); ob.cal(); } } class abc { JFrame f; JButton b; void cal() { f=new JFrame(); Container c=f.getContentPane(); c.setLayout(new FlowLayout()); b=new JButton("OK"); c.add(b); f.setSize(200,200); f.setVisible(true); f.setResizable(false); } } class GUI17 { public static void main(String asd[]) { abc ob=new abc(); ob.cal(); } } class Ex { public static void main(String []a) {
  • 9.
    int c =2; intd=0; try { System.out.println("show="+(c/d)); } catch(arithmaticException e) { System.out.println("show error"); } } } import javax.swing.*; class f { public static void main(String args[]) { int a; int b; int s; String in; in = JOptionpane.showInputDialog("Enter the number a=") a = Integer.IarseInt(in); in = JOptionpane.showInputDialog("Enter the number b=") b = Integer.parseInt(in); s = a + b; System.out.println("sum = " + s); } } import javax.swing.*; class fd { public static void main(String args[]) { int a; int c; String in; in = JOptionPane.showInputDialog("enter any number:"); a = Integer.parseInt(in); for(c = 1;c<=10;c++);
  • 10.
    { System.out.println(a + "*"+ c + "=" + a*c); } } } class four { public static void main(String args[]) { int a = 1; int b = 2; int c = 3; int d = 4; int s; int mul; s = a + b; mul = c * d; System.out.println("SUM IS " + s); System.out.println("MUL IS " + mul); } } class fun { public static void main(String app[]) { int a,b,c,d = 1; System.out.println(" * * *"); System.out.println(" * 0 0 *"); System.out.println(" * *"); for(a=1;a<2;a++) { System.out.println(" * ---- *"); } System.out.println(" * * *"); for(b=1;b<3;b++) { System.out.println(" * "); } System.out.println(" *** ***"); System.out.println(" * *"); System.out.println(" * *"); System.out.println(" * *");
  • 11.
    for(c=1;c<6;c++) { System.out.println(" *********"); } for(d=1;d<5;d++) { System.out.println(" **"); } System.out.println(" ** **"); } } import javax.swing.*; class g { public static void main(String args[]) { int a; int b; int s; String in; in = JOptionPane.showInputDialog("Enter a:"); a = Integer.parseInt(in); in = JOptionPane.showInputDialog("Enter b:"); b = Integer.parseInt(in); s = a + b; JOptionPane.showInputDialog(null,"sum="+s); } } import java.awt.*; import javax.swing.*; class guit { JFrame f; JButton b; JButton b1; JButton b2; JButton b3; JTextField t; void creatgui()// no spacing { f = new JFrame();// ; Container c = f.getContentPane();
  • 12.
    c.setLayout(new FlowLayout()); t =new JTextField(20);//no spacing t = new JTextField(20); b = new JButton("Button");// no spacing b1 = new JButton("Button1"); b2 = new JButton("Button2"); b3 = new JButton("+"); c.add(t);// small t instead T c.add(b); c.add(b1); c.add(b2); c.add(b3); f.setSize(100,100);// no spacing // see f and S f.setVisible(true); // see f and V } } class GUI { public static void main(String app[]) { guit g = new guit(); g.creatgui();// . // no pass } } import java.awt.*; import javax.swing.*; class guit { JFrame f; JButton b; JButton b1; JButton b2; JButton b3; JTextField t; void creatgui()// no spacing { f = new JFrame();// ; Container c = f.getContentPane(); c.setLayout(new FlowLayout());
  • 13.
    t = newJTextField(20);//no spacing t = new JTextField(20); b = new JButton("Button");// no spacing b1 = new JButton("Button1"); b2 = new JButton("Button2"); b3 = new JButton("+"); c.add(t);// small t instead T c.add(b); c.add(b1); c.add(b2); c.add(b3); f.setSize(100,100);// no spacing // see f and S f.setVisible(true); // see f and V } } class guit1 extends guit { void new() { JButton b4; b4 = new JButton("B4"); c.add(b4); } } class GUI1 { public static void main(String app[]) { guit g = new guit(); g.creatgui();// . guit1 k = new guit1(); k.new(); k.creatgui(); // no pass } } import javax.swing.*; import java.awt.*; class g
  • 14.
    { JLabel L; JFrame F; JButtonB1,B2,B3,B4,B5,B6,B7,B8,B9,B10,B11,B12,B13,B14,B15,B16; JTextField T; void creat() { L=new JLabel("Calculator"); L.setForeground(Color.ORANGE); L.setFont(new Font("Serif",Font.PLAIN,25)); F=new JFrame("Shahzad's Calculater"); F.setBackground(Color.PINK); Container C=F.getContentPane(); C.setLayout(new BorderLayout()); JPanel P=new JPanel(); P.setLayout(new GridLayout(4,4,10,15)); P.setBackground(Color.BLACK);//pink T=new JTextField(20); T.setFont(new Font("Serif",Font.PLAIN,25)); B1=new JButton("1"); B1.setBackground(Color.RED); B1.setForeground(Color.BLACK); B2=new JButton("2"); B2.setBackground(Color.ORANGE); B2.setForeground(Color.WHITE); B3=new JButton("3"); B3.setBackground(Color.ORANGE); B3.setForeground(Color.WHITE); B4=new JButton("4"); B4.setBackground(Color.ORANGE); B4.setForeground(Color.WHITE); B5=new JButton("5"); B5.setBackground(Color.RED); B5.setForeground(Color.WHITE); B6=new JButton("6"); B6.setBackground(Color.ORANGE); B6.setForeground(Color.WHITE); B7=new JButton("7"); B7.setBackground(Color.ORANGE); B7.setForeground(Color.WHITE); B8=new JButton("8"); B8.setBackground(Color.ORANGE); B8.setForeground(Color.WHITE); B9=new JButton("9"); B9.setBackground(Color.RED); B9.setForeground(Color.WHITE); B10=new JButton("0"); B10.setBackground(Color.ORANGE); B10.setForeground(Color.WHITE); B11=new JButton("c"); B11.setBackground(Color.ORANGE); B11.setForeground(Color.WHITE); B12=new JButton("="); B12.setBackground(Color.ORANGE); B12.setForeground(Color.WHITE); B13=new JButton("+"); B13.setBackground(Color.ORANGE); B13.setForeground(Color.WHITE); B14=new JButton("-"); B14.setBackground(Color.ORANGE); B14.setForeground(Color.WHITE); B15=new JButton("/"); B15.setBackground(Color.RED); B15.setForeground(Color.WHITE); B16=new JButton("x"); B16.setBackground(Color.ORANGE); B16.setForeground(Color.WHITE); P.add(B1); P.add(B2); P.add(B3); P.add(B13); P.add(B4); P.add(B5); P.add(B6); P.add(B14); P.add(B7); P.add(B8); P.add(B9); P.add(B16);
  • 15.
    P.add(B10); P.add(B11); P.add(B12); P.add(B15); C.add(T,BorderLayout.NORTH); C.add(L,BorderLayout.SOUTH); C.add(P,BorderLayout.CENTER); F.setSize(400,400); F.setVisible(true); } } class GUI2 { public staticvoid main(String asd[]) { g r=new g(); r.creat(); } } import java.awt.*; import javax.swing.*; class gui { JFrame f; JButton b; JTextField t; void creat() { f = new JFrame(); Container c = f.getContentPane();//p Capital c.setLayout(new FlowLayout()); t = new JTextField(10); b = new JButton("BUTTON"); c.add(t); c.add(b); f.setSize(200,200); f.setVisible(true); } } class GUI3 { public static void main(String app[])
  • 16.
    { gui g =new gui(); g.creat(); } } import java.awt.*; import javax.swing.*; class gui { void ggg() { JFrame f; JButton b; JButton b1; JButton b2; JTextField t; f = new JFrame(); Container c = f.getContentPane(); c.setLayout(new GridLayout(2,1,200,200)); t = new JTextField(5); b = new JButton("b"); b1 = new JButton("b1"); b2 = new JButton("b2"); c.add(t); c.add(b); c.add(b1); c.add(b2); f.setSize(100,100); f.setVisible(true); } } class GUI4 { public static void main(String args[]) { gui g = new gui(); g.ggg(); } } import java.awt.*; import javax.swing.*; class m
  • 17.
    { JFrame f; JButton b;JButton b1; JButton b2; JButton b3; JButton b4; JButton b5; JButton b6; JButton b7; JButton b8; JButton b9; JButton b10; JButton b11; JButton b12; JButton b13; JButton b14; JTextField t; void method() { f = new JFrame(); Container c = f.getContentPane(); c.setLayout(new BorderLayout()); t = new JTextField(5); b = new JButton("0"); b1 = new JButton ("1"); b2 = new JButton ("2"); b3 = new JButton ("3"); b4 = new JButton ("4"); b5 = new JButton ("5"); b6 = new JButton ("6"); b7 = new JButton ("7"); b8 = new JButton ("8"); b9 = new JButton ("9"); b10 = new JButton ("*"); b11 = new JButton ("/"); b12 = new JButton ("+"); b13 = new JButton ("-"); b14 = new JButton ("ReSet"); c.add(t, BorderLayout.NORTH); c.add(b, BorderLayout.EAST); c.add(b1, BorderLayout.WEST); c.add(b2, BorderLayout.SOUTH); c.add(b3, BorderLayout.CENTER); c.add(b4, BorderLayout.EAST); c.add(b5); c.add(b6); c.add(b7); c.add(b8); c.add(b9); c.add(b10); c.add(b11); c.add(b12); c.add(b13); c.add(b14); f.setSize(100,100); f.setVisible(true);
  • 18.
    } } class GUI5 { public staticvoid main(String args[]) { m g = new m(); g.method(); } } import java.awt.*; import javax.swing.*; public class CalculatorGUI { JFrame fCalc; JButton b1, b2, b3, b4, b5, b6, b7, b8, b9, b0; JButton bPlus, bMinus, bMul, bPoint, bEqual, bClear; JPanel pButtons; JTextField tfAnswer; JLabel lMyCalc; public void initGUI ( ) { //used for setting layout of calculator fCalc = new JFrame(); b0 = new JButton("0"); b1 = new JButton("1"); b2 = new JButton("2"); b3 = new JButton("3"); b4 = new JButton("4"); b5 = new JButton("5"); b6 = new JButton("6"); b7 = new JButton("7"); b8 = new JButton("8"); b9 = new JButton("9"); bPlus = new JButton("+"); bMinus = new JButton("-"); bMul = new JButton("*"); bPoint = new JButton("."); bEqual = new JButton("="); bClear = new JButton("C"); tfAnswer = new JTextField(); lMyCalc = new JLabel("My Clacualator");
  • 19.
    //creating panel objectand setting its layout pButtons = new JPanel (new GridLayout(4,4)); //adding components (buttons) to panel pButtons.add(b1); pButtons.add(b2); pButtons.add(b3); pButtons.add(bClear); pButtons.add(b4); pButtons.add(b5); pButtons.add(b6); pButtons.add(bMul); pButtons.add(b7); pButtons.add(b8); pButtons.add(b9); pButtons.add(bMinus); pButtons.add(b0); pButtons.add(bPoint); pButtons.add(bPlus); pButtons.add(bEqual); Container con = fCalc.getContentPane(); con.setLayout(new BorderLayout()); //adding components to container con.add(tfAnswer, BorderLayout.NORTH); con.add(lMyCalc, BorderLayout.SOUTH); con.add(pButtons, BorderLayout.CENTER); fCalc.setSize(300, 300); fCalc.setVisible(true); } // end of initGUI method //default constructor public CalculatorGUI ( ) { initGUI(); } //main method class GUI6 { public static void main(String args[ ]) { CalculatorGUI calGUI = new CalculatorGUI(); } } import java.awt.*; import javax.swing.*; class gui
  • 20.
    { JFrame f; JTextField t; JButtonb; void gui() { f = new JFrame(); Container c = f.getContentPane(); c.setLayout(new FlowLayout()); b = new JButton("Button"); t = new JTextField(10); c.add(b); c.add(t); f.setSize(1,1); f.setVisible(true); } } class GUI7 { public static void main (String app[]) { gui p = new gui(); p.gui(); } } import javax.swing.*; import java.awt.*; import java.awt.event.*; class gui { JFrame f = new JFrame(); JTextField t = new JTextField(20); JButton b = new JButton("B"); JButton b1 = new JButton("B1"); void g () { Container c = f.getContentPane(); c.setLayout(new FlowLayout()); c.add(t); c.add(b); c.add(b1); t.setBounds(10,10,10,10); b.setBounds(10,10,10,10);
  • 21.
    b1.setBounds(10,10,10,10); f.setVisible(true); f.setSize(100,100); b.addActionListener(new bAct()); } public classbAct implements ActionListener { public void actionPerformed(ActionEvent e)// public is necessory { String n = "1"; t.setText(n); } } } class GUI8 { public static void main(String app[]) { gui ob = new gui(); ob.g(); } } import javax.swing.*; import java.awt.*; class gui { JFrame f; JTextField t,t1,t2,t3,t4,t5,t6; JButton b,b1,b2,b3; void g() { f = new JFrame(); Container c = f.getContentPane(); c.setLayout(new GridLayout(2,3)); t = new JTextField(10); t1 = new JTextField(10); t2 = new JTextField(10); t3 = new JTextField(10); t4 = new JTextField(10); t5 = new JTextField(10); t6 = new JTextField(10); c.add(t);
  • 22.
    c.add(t1); c.add(t2); c.add(t3); c.add(t4); c.add(t5); c.add(t6); b = newJButton("BUTTON"); b1 = new JButton("B1"); b2 = new JButton("b2"); b3 = new JButton("b3"); c.add(b1); c.add(b2); c.add(b3); f.setSize(100,100); f.setVisible(true); } } class GUI9 { public static void main(String app[]) { gui ob = new gui(); ob.g(); } } import javax.swing.*;// libraries import java.awt.*; class gui { JFrame f; JButton b; JButton b1; JButton b2; JButton b3; JButton b4; void g() { f = new JFrame(); Container c = f.getContentPane(); c.setLayout(new BorderLayout()); b = new JButton("b");
  • 23.
    b1 = newJButton("b1"); b2 = new JButton("b2"); b3 = new JButton("b3"); b4 = new JButton("b4"); c.add(b, BorderLayout.NORTH); c.add(b1, BorderLayout.SOUTH); c.add(b2, BorderLayout.EAST); c.add(b3, BorderLayout.WEST); c.add(b4, BorderLayout.CENTER); f.setSize(100,100); f.setVisible(true); } } class GUI10 { public static void main(String app[]) { gui ob = new gui(); ob.g(); } } import javax.swing.*; import java.awt.*; import java.awt.event.*; class gui implements ActionListener { JFrame f=new JFrame(); JButton b1,b2,b3,b4; JTextField t1,t2; void gg() { Container c = f.getContentPane(); c.setLayout(new FlowLayout()); b1= new JButton("+"); b2= new JButton("-"); b3= new JButton("*"); b4= new JButton("%"); t1= new JTextField(20); t2 = new JTextField(20); c.add(t1); c.add(t2);
  • 24.
    c.add(b1); c.add(b2); c.add(b3); c.add(b4); f.setSize(400,400); f.setVisible(true); b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this); b4.addActionListener(this); } public void actionPerformed(ActionEvente) { Double x,y,z; if (e.getSource()==b1) { x = Double.parseDouble(t1.getText() ); y = Double.parseDouble(t2.getText()); z = x+ y; JOptionPane.showMessageDialog(null, "Ans" + z); } else if(e.getSource()==b2) { //2=t2.getText(); x = Double.parseDouble(t1.getText() ); y = Double.parseDouble(t2.getText()); z = x+ y; JOptionPane.showMessageDialog(null, "Ans" + z); } else if(e.getSource()==b3) { x = Double.parseDouble(t1.getText() ); y = Double.parseDouble(t2.getText()); z = x+ y; JOptionPane.showMessageDialog(null, "Ans" + z); } else if(e.getSource()==b4) { x = Double.parseDouble(t1.getText() ); y = Double.parseDouble(t2.getText()); z = x+ y; JOptionPane.showMessageDialog(null, "Ans" + z); }
  • 25.
    } } class GUI11 { public staticvoid main(String app[]) { gui ob = new gui(); ob.gg(); } } import javax.swing.*; import java.awt.*; import java.awt.event.*; class abc { String dis=""; char result; double num1,num2; JFrame f; JLabel l=new JLabel("Calculator"); JTextField t; JButton b1,b2,b3,b4,b5,b6,b7,b8,b9,b0,bp,bs,bm,bd,bc,beq; abc() { f=new JFrame(); Container c=f.getContentPane(); c.setLayout(new BorderLayout()); t=new JTextField(10); JPanel p=new JPanel(new GridLayout(4,4,2,2)); b1=new JButton("1"); b2=new JButton("2"); b3=new JButton("3"); b4=new JButton("4"); b5=new JButton("5"); b6=new JButton("6"); b7=new JButton("7"); b8=new JButton("8"); b9=new JButton("9"); b0=new JButton("0"); bp=new JButton("+"); bs=new JButton("-"); bm=new JButton("*"); bd=new JButton("/");
  • 26.
    beq=new JButton("="); bc=new JButton("c"); p.add(b1); p.add(b2); p.add(b3); p.add(bp); p.add(b4); p.add(b5); p.add(b6); p.add(bs); p.add(b7); p.add(b8); p.add(b9); p.add(bm); p.add(beq); p.add(b0); p.add(bc); p.add(bd); c.add(t,BorderLayout.NORTH); c.add(p,BorderLayout.CENTER); c.add(l,BorderLayout.SOUTH); f.setSize(400,400); f.setVisible(true); //f.setResizable(false); button1ob1=new button1(); b1.addActionListener(ob1); button2 ob2=new button2(); b2.addActionListener(ob2); button3 ob3=new button3(); b3.addActionListener(ob3); button4 ob4=new button4(); b4.addActionListener(ob4); button5 ob5=new button5(); b5.addActionListener(ob5); button6 ob6=new button6(); b6.addActionListener(ob6); button7 ob7=new button7(); b7.addActionListener(ob7); button8 ob8=new button8(); b8.addActionListener(ob8); button9 ob9=new button9(); b9.addActionListener(ob9); buttonp obp=new buttonp(); bp.addActionListener(obp);
  • 27.
    buttons obs=new buttons(); bs.addActionListener(obs); buttonmobm=new buttonm(); bm.addActionListener(obm); buttond obd=new buttond(); bd.addActionListener(obd); buttonc obc=new buttonc(); bc.addActionListener(obc); buttoneq obeq=new buttoneq(); beq.addActionListener(obeq); button0 ob0=new button0(); b0.addActionListener(ob0); } class button1 implements ActionListener { public void actionPerformed(ActionEvent e) { t.setText(""); dis=t.getText(); t.setText(dis+"1"); } } class button2 implements ActionListener { public void actionPerformed(ActionEvent e) { t.setText(""); dis=t.getText(); t.setText(dis+"2"); } } class button3 implements ActionListener { public void actionPerformed(ActionEvent e) { t.setText(""); dis=t.getText(); t.setText(dis+"3"); } } class button4 implements ActionListener { public void actionPerformed(ActionEvent e)
  • 28.
    { t.setText(""); dis=t.getText(); t.setText(dis+"4"); } } class button5 implementsActionListener { public void actionPerformed(ActionEvent e) { t.setText(""); dis=t.getText(); t.setText(dis+"5"); } } class button6 implements ActionListener { public void actionPerformed(ActionEvent e) { t.setText(""); dis=t.getText(); t.setText(dis+"6"); } } class button7 implements ActionListener { public void actionPerformed(ActionEvent e) { t.setText(""); dis=t.getText(); t.setText(dis+"7"); } } class button8 implements ActionListener { public void actionPerformed(ActionEvent e) { t.setText(""); dis=t.getText(); t.setText(dis+"8"); } } class button9 implements ActionListener {
  • 29.
    public void actionPerformed(ActionEvente) { t.setText(""); dis=t.getText(); t.setText(dis+"9"); } } class button0 implements ActionListener { public void actionPerformed(ActionEvent e) { t.setText(""); dis=t.getText(); t.setText(dis+"0"); } } class buttonp implements ActionListener { public void actionPerformed(ActionEvent e) { num1=Double.parseDouble(t.getText()); t.setText("+"); result='+'; } } class buttons implements ActionListener { public void actionPerformed(ActionEvent e) { num1=Double.parseDouble(t.getText()); t.setText("-"); result='-'; } } class buttonm implements ActionListener { public void actionPerformed(ActionEvent e) { num1=Double.parseDouble(t.getText()); t.setText("*"); result='*'; }
  • 30.
    } class buttond implementsActionListener { public void actionPerformed(ActionEvent e) { num1=Double.parseDouble(t.getText()); t.setText("/"); result='/'; } } class buttoneq implements ActionListener { public void actionPerformed(ActionEvent e) { num2=Double.parseDouble(t.getText()); if(result=='+') { num2=num1+num2; t.setText(Double.toString(num2)); } else if(result=='-') { num2=num1-num2; t.setText(Double.toString(num2)); } if(result=='*') { num2=num1*num2; t.setText(Double.toString(num2)); } if(result=='/') { num2=num1/num2; t.setText(Double.toString(num2)); } } } class buttonc implements ActionListener { public void actionPerformed(ActionEvent e) { dis=""; num1=0; num2=0;
  • 31.
    t.setText(""); } } } class GUI12 { public staticvoid main(String asd[]) { abc obj=new abc(); } } import javax.swing.*; import java.awt.*; class gui { JFrame f; JButton b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,b21,b22,b23,b24,b25,b2 6,b27,b28,b29,b30, b31,b32,b33,b34; JTextField t,t1; JPanel p,p1,p2; void g() { f = new JFrame(); Container c = f.getContentPane(); c.setLayout(new BorderLayout()); t=new JTextField(30); t1 = new JTextField(30); b0=new JButton("0"); b1=new JButton("1"); b2=new JButton("2");b2.setBackground(Color.BLUE); b3=new JButton("3"); b4=new JButton("4"); b5=new JButton("5"); b6=new JButton("6"); b7=new JButton("7"); b8=new JButton("8"); b9=new JButton("9"); b10=new JButton("10"); b11=new JButton("11"); b12=new JButton("12"); b13=new JButton("13");
  • 32.
    b14=new JButton("14"); b15=new JButton("15"); b16=newJButton("16"); b17=new JButton("17"); b18=new JButton("18"); b19=new JButton("19"); b20=new JButton("20"); b21=new JButton("21"); b22=new JButton("22"); b23=new JButton("23"); b24=new JButton("24"); b25=new JButton("25"); b26=new JButton("26"); b27=new JButton("27"); b28=new JButton("28"); b29=new JButton("29"); b30=new JButton("30"); b31=new JButton("31"); b32=new JButton("32"); b33=new JButton("33"); b34=new JButton("34"); p = new JPanel(new GridLayout(5,1,5,5)); p.setBackground(Color.RED); p1 = new JPanel(new GridLayout(8,3,5,5)); p1.setBackground(Color.BLUE); p2 = new JPanel(new GridLayout(3,5,5,5)); p2.setBackground(Color.GREEN); p.add(b0); p.add(b1); p.add(b2); p.add(b3); p.add(b4); p1.add(b5); p1.add(b6); p1.add(b7); p1.add(b8); p1.add(b9); p1.add(b10); p1.add(b11); p1.add(b12); p1.add(b13); p1.add(b14); p1.add(b21); p1.add(b15);
  • 33.
  • 34.
    JButton b,b1,b2; JTextField t,t1,t2,t3; JPanelp,p1,p2,p3,p4; void g() { f=new JFrame(); Container c = f.getContentPane(); c.setLayout(new BorderLayout());//Grid b=new JButton("+"); b1=new JButton("-"); b2=new JButton("="); t=new JTextField(30); t1=new JTextField(30); t2=new JTextField(30); t3=new JTextField(30); p=new JPanel(new GridLayout(1,1,5,5)); p.setBackground(Color.GREEN); p1=new JPanel(new FlowLayout(500)); p2=new JPanel(new GridLayout()); p3=new JPanel(new GridLayout(1,1,5,5)); p4=new JPanel(new GridLayout(2,1,5,5)); p3.add(t3); p.add(t); p1.add(t1); p2.add(t2); p4.add(b); p4.add(b1); p4.add(b2); c.add(t3, BorderLayout.NORTH); c.add(t1, BorderLayout.WEST); c.add(p4, BorderLayout.CENTER); c.add(t2, BorderLayout.EAST); c.add(t, BorderLayout.SOUTH); f.setSize(400,400); f.setVisible(true); } } class GUI14 { public static void main(String app[]) { gui ob = new gui(); ob.g();
  • 35.
    } } import javax.swing.*; import java.awt.*; classgui { JFrame f; JTextField t,t1; JButton b,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18; JPanel p,p1; void g() { Container c=f.getContentPane();//no space getContentPane c.setLayout(new BorderLayout());//no space setLayout t=new JTextField(10); t1=new JTextField(5); b=new JButton("0"); b1=new JButton("1"); b2=new JButton("2"); b3=new JButton("3"); b4=new JButton("4"); b5=new JButton("5"); b6=new JButton("6"); b7=new JButton("7"); b8=new JButton("8"); b9=new JButton("9"); b10=new JButton("10"); b11=new JButton("11"); b12=new JButton("12"); b13=new JButton("13"); b14=new JButton("14"); b15=new JButton("15"); b16=new JButton("16"); b17=new JButton("17"); b18=new JButton("18"); p=new JPanel(new GridLayout(1,1,2,2)); p1=new JPanel(new FlowLayout()); p.add(t); p.add(t); p1.add(b); p1.add(b1); p1.add(b2);
  • 36.
    p1.add(b3); p1.add(b4); p1.add(b5); p1.add(b6); p1.add(b7); p1.add(b8); p1.add(b9); p1.add(b10); p1.add(b11); p1.add(b12); p1.add(b13); p1.add(b14); p1.add(b15); p1.add(b16); p1.add(b18); c.add(p,BorderLayout.NORTH); c.add(p1,BorderLayout.CENTER); f.setSize(200,200); f.setVisible(true); } } class GUI15 { public staticvoid main(String app[]) { gui ob = new gui(); ob.g(); } } import javax.swing.*; import java.awt.*; class gui { JFrame f; JTextField t,t1; JButton b,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15; void g() { Container c=f.getContentPane(); c.setLayout(new GridLayout(4,4)); t = new JTextField(5); t1 = new JTextField(5); b = new JButton("0");
  • 37.
    b1 = newJButton("1"); b2 = new JButton("2"); b3 = new JButton("3"); b4 = new JButton("4"); b5 = new JButton("5"); b6 = new JButton("6"); b7 = new JButton("7"); b8 = new JButton("8"); b9 = new JButton("9"); b10 = new JButton("/"); b11 = new JButton("+"); b12 = new JButton("-"); b13 = new JButton("*"); b14 = new JButton("="); b15 = new JButton("."); c.add(t); c.add(t1); c.add(b); c.add(b1); c.add(b2); c.add(b3); c.add(b4); c.add(b5); c.add(b6); c.add(b7); c.add(b8); c.add(b9); c.add(b10); c.add(b11); c.add(b12); c.add(b13); c.add(b14); c.add(b15); f.setSize(200,200); f.setVisible(true); } } class GUI16 { public static void main(String app[]) //missing method body or declare abstract { gui ob = new gui(); ob.g(); }
  • 38.
    } import javax.swing.*; import java.awt.*; importjava.awt.event.*; class abc { JFrame f; JButton b; void cal() { f=new JFrame(); Container c=f.getContentPane(); c.setLayout(new FlowLayout()); b=new JButton("Hello"); c.add(b); f.setSize(200,200); f.setVisible(true); f.setResizable(false); clsb ob=new clsb(); b.addActionListener(ob); } class clsb implements ActionListener { public void actionPerformed(ActionEvent a) { JOptionPane.showMessageDialog(null,"Hello is processing"); } } } class GUI17 { public static void main(String asd[]) { abc ob=new abc(); ob.cal(); } } import javax.swing.*; import java.awt.*; import java.awt.event.*; class gui
  • 39.
    { int i; String n; JFramef; JButton b; JButton b1; JTextField t; void g() { f = new JFrame(); Container c = f.getContentPane(); c.setLayout(new FlowLayout()); b = new JButton("B"); b1 = new JButton("B1"); t = new JTextField(50); c.add(t); c.add(b); c.add(b1); f.setSize(200,200); f.setVisible(true); button ob = new button();//no words of "class" will be used 9mistakes b.addActionListener(ob); button1 ob1 = new button1(); b1.addActionListener(ob1); } class button implements ActionListener//mis (); { public void actionPerformed(ActionEvent a)//mis ; { t.setText(""); n=t.getText(); t.setText(n+"Hello"); } } class button1 implements ActionListener//no (); { public void actionPerformed(ActionEvent a)//mis ; { t.setText(""); n=t.getText(); for(i=0;i<5;i=i++) { t.setText(n+"G"); t.setText(i+"READ THIS");
  • 40.
    JOptionPane.showMessageDialog(null,"TERI PAN DE"); JOptionPane.showMessageDialog(null,"BEGARAT,SALA"); JOptionPane.showMessageDialog(null,"PCS"); } } } } class GUI18 { public static void main(String app[]) //mis ; { gui obj = new gui(); obj.g(); } } import javax.swing.*; import java.awt.*; import java.awt.event.*; class gui { String s; JFrame f; JButton bc,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10; JTextField t; void g() //MIS; { f = new JFrame(); Container c = f.getContentPane(); c.setLayout(new GridLayout(3,3,5,5)); bc=new JButton("C"); b0=new JButton("0"); b1=new JButton("1"); b2=new JButton("2"); b3=new JButton("3"); b4=new JButton("4"); b5=new JButton("5"); b6=new JButton("6"); b7=new JButton("7"); b8=new JButton("8");
  • 41.
    b9=new JButton("9"); b10=new JButton("10"); t=newJTextField(20); c.add(t); c.add(bc); c.add(b0); c.add(b1); c.add(b2); c.add(b3); c.add(b4); c.add(b5); c.add(b6); c.add(b7); c.add(b8); c.add(b9); c.add(b10); f.setSize(200,200); f.setVisible(true); button0 ob00 = new button0(); b0.addActionListener(ob00); button1 ob1 = new button1(); b1.addActionListener(ob1); button2 ob2 = new button2(); b2.addActionListener(ob2); button3 ob3 = new button3(); b3.addActionListener(ob3); button4 ob4 = new button4(); b4.addActionListener(ob4); button5 ob5 = new button5(); b5.addActionListener(ob5); button6 ob6 = new button6(); b6.addActionListener(ob6); button7 ob7 = new button7(); b7.addActionListener(ob7); button8 ob8 = new button8(); b8.addActionListener(ob8);
  • 42.
    button9 ob9 =new button9(); b9.addActionListener(ob9); button10 ob10 = new button10(); b10.addActionListener(ob10); button0 ob0 = new button0(); b0.addActionListener(ob0); buttonc obc = new buttonc(); bc.addActionListener(obc); } //FOR "0" class button0 implements ActionListener { public void actionPerformed(ActionEvent a) { t.setText("0"); s = t.getText(); t.setText(s+"0"); } } // FOR "1" class button1 implements ActionListener { public void actionPerformed(ActionEvent a) { t.setText(""); s=t.getText(); t.setText(s+"1"); } } //FOR "2" class button2 implements ActionListener { public void actionPerformed(ActionEvent a) { t.setText(""); s=t.getText(); t.setText(s+"2"); }
  • 43.
    } //FOR "3" class button3implements ActionListener { public void actionPerformed(ActionEvent a) { t.setText(""); s=t.getText(); t.setText(s+"3"); } } //FOR "4" class button4 implements ActionListener { public void actionPerformed(ActionEvent a) { t.setText(""); s=t.getText(); t.setText(s+"4"); } } //FOR "5" class button5 implements ActionListener { public void actionPerformed(ActionEvent a) { t.setText(""); s=t.getText(); t.setText(s+"5"); } } //FOR "6" class button6 implements ActionListener { public void actionPerformed(ActionEvent a) { t.setText("");
  • 44.
    s=t.getText(); t.setText(s+"6"); } } //FOR "7" class button7implements ActionListener { public void actionPerformed(ActionEvent a) { t.setText(""); s=t.getText(); t.setText(s+"7"); } } //FOR "8" class button8 implements ActionListener { public void actionPerformed(ActionEvent a) { t.setText(""); s=t.getText(); t.setText(s+"8"); } } // FOR "9" class button9 implements ActionListener { public void actionPerformed(ActionEvent a) { t.setText(""); s=t.getText(); t.setText(s+"9"); } } // FOR "10" class button10 implements ActionListener {
  • 45.
    public void actionPerformed(ActionEventa) { t.setText(""); s=t.getText(); t.setText(s+"10"); } } // FOR "CLEAR" class buttonc implements ActionListener { public void actionPerformed(ActionEvent a) { t.setText(""); s=t.getText(); t.setText(s+" "); } } } class GUI19 { public static void main(String app[]) { gui obj = new gui(); obj.g(); } } class pa { int a; int b; void show() { System.out.println("value of a = " + a); System.out.println("value of b = " + b); } } class ch extends pa { } class in0 { public static void main(String app[])
  • 46.
    { pa ob =new pa(); //(;) semicolon laganay hein ob.a = 2; //other wise it will show (file not find) ob.b = 3; ob.show(); ch ob1 = new ch(); ob1.a = 4; ob1.b = 5; ob1.show(); } } class pa { int a; int b; int s; int p; void show() { System.out.println("value of a = " + a); System.out.println("value of b = " + b); s = a + b; System.out.println("value of sum = " + s); } } class chi extends pa { void mul() { p = a*b; System.out.println("multi is :" + p); } } class in1 { public static void main(String app[]) { pa ob = new pa(); ob.a = 2; ob.b = 3; ob.show(); chi ob1 = new chi(); ob1.a = 4;
  • 47.
    ob1.b = 5; ob1.show(); ob1.mul(); } } classpa { int a; int b; void show() { System.out.println("value of a = " + a); System.out.println("value of b = " + b); } } class ch extends pa { } class inh { public static void main(String app[]) { pa ob = new pa(); //(;) semicolon laganay hein pa.a = 2; //other wise it will show (file not find) pa.b = 3; pa.show(); ch ob1 = new ch(); ob1.a = 4; ob1.b = 5; ob1.show(); } } class parant { int a; int b; int c; void set() { System.out.println("value of a is = " + a); System.out.println("value of b is = " + b); System.out.println("value of c is = " + c);
  • 48.
    } int math() //; will show miss method body { return a+b+c; } class child extends parant { } } class inh0 { public static void main(String opps[]) { parant ob = new parant(); parant ob1 = new parant(); ob.a = 2; ob.b = 3; ob.c = 4; ob.set(); int e = ob.math(); System.out.println(" ob1.a = 5; ob1.b = 6; ob1.c = 7; ob1.set(); ob1.math(); } } import javax.swing.*; class inplus { public static void main(String app[]) { int a; int b; int c; int d; int s; String in; in = JOptionPane.showInputDialog("Enter a="); a = Integer.parseInt(in); in = JOptionPane.showInputDialog("Enter b="); b = Integer.parseInt(in);
  • 49.
    in = JOptionPane.showInputDialog("Enterc="); c = Integer.parseInt(in); in = JOptionPane.showInputDialog("Enter d="); d = Integer.parseInt(in); s = a + b + c + d; System.out.println("Sum of no is =" + s); } } import javax.swing.*; class input { public static void main(String app[]) { int a; int b; int c; String in; in = JOptionPane.showInputDialog("Enter 1st no="); a = Integer.parseInt(in); in = JOptionPane.showInputDialog("Enter 2nd no="); b = Integer.parseInt(in); c = a * b; System.out.println("Multiplication is =" + c); } } public interface person { void speak(); } class teacher implements person // implement spellings { void speak() { System.out.println("Teacher"); } } class interface00 { public static void main(String args[]) { person p; p = new person();
  • 50.
    p.speak(); } } class A { int a; intb; void show() { System.out.println( a + b); } } class B extends A { int c; void showc() { System.out.println("c" + c); } } class m { public static void main(String args[]) { A ob1 = new A(); ob1.a = 5; ob1.b = 6; ob1.show(); B ob2 = new B(); ob2.a = 3; ob2.b = 2; ob2.c = 1; ob2.show(); ob2.showc(); } } class box { double w; double h; double d; double v;
  • 51.
    void volume() { v =w*h*d; System.out.println("Volume is:"); System.out.println(+ v); } } class m0000 { public static void main(String args[]) { box mybox = new box(); box mybox1 = new box(); mybox.w = 10; mybox.h = 7; mybox.d = 5; mybox1.h = 3; mybox1.w = 4; mybox1.d = 6; mybox.volume(); mybox1.volume(); } } class box { int h; int b; int area() { return h*b; } int perimeter() { return 2*b+h; } } class m000 { public static void main(String app[]) { box b1 = new box(); b1.h = 2; b1.b = 3;
  • 52.
    int a =b1.area(); box b2 = new box(); b2.h = 5; b2.b = 2; int c = b2.perimeter(); System.out.println("Area of box 1 = " + a); System.out.println("Perimeter of box 2 = " + c); } } class circle { int r; void set() { System.out.println("R is = " + r); } double Calcarea() { return 3.14*r*r; } double Calccircum() { return 2*3.14*r; } } class m00 { public static void main(String app[]) { circle ob1 = new circle(); circle ob2 = new circle(); ob1.r = 2; ob2.r = 3; ob1.set(); ob2.set(); double f = ob1.Calcarea(); double g = ob1.Calccircum(); System.out.println("Area of ob1 is = " + f); System.out.println("circumference of ob1 is = " + g); double d = ob2.Calcarea(); double e = ob2.Calccircum();
  • 53.
    System.out.println("Area of ob2is = " + d); System.out.println("circumference of ob2 is = " + e); System.out.println("new is = " + (e * 4)); } } class wq { double l; double h; double a; double p; void area() { a = l * h; System.out.println("The area is:" + a); } void perimeter() { p = 2*l + 2*h; System.out.println("Perimeter is:" + p); } } class m0 { public static void main(String args[]) { wq obj = new wq(); obj.l = 10; obj.h = 5; obj.area(); obj.perimeter(); } } class object { int a,b,c; void set() { a = 0; b = 0; c = 0; }
  • 54.
    int sum() { return a+b+c; } floatavg() { return (a+b+c)/3; } } class m1 { public static void main(String app[]) { object ob = new object(); object ob1 = new object(); object ob2 = new object(); object ob3 = new object(); ob.a = 5; ob.b = 3; ob.c = 4; ob1.a = 5; ob1.b = 6; ob1.c = 7; ob2.a = 1; ob2.b = 2; ob2.c = 3; ob3.a = 4; ob3.b = 5; ob3.c = 6; int s = ob.sum(); float z = ob.avg(); int t = ob1.sum(); int q = ob2.sum(); float r = ob3.avg(); System.out.println("Sum is = " + s); System.out.println("Average is = " + z); System.out.println("Sum of 2 is = " + t); System.out.println("Sum of ob2 is =" + q); System.out.println("Avg of ob3 is = " + r); } } class object {
  • 55.
    int p,q; void set() { p= q = 5; } void show() { System.out.println("Value of P is = " + p); System.out.println("Value of Q is = " + q); } int sum() { return p+q; } } class m3 { public static void main(String app[]) { object ob1 = new object(); ob1.p = 3; ob1.q = 4; ob1.show(); int a = ob1.sum(); System.out.println("Sum is = " + a); } } class object { int a,b,c; void set() { a = b = c = 0; } void show() { System.out.println("Value of a = " + a); System.out.println("Value of b = " + b); System.out.println("Value of c = " + c); } int sum() { return a+b+c;
  • 56.
    } int sub() { return a+b-c; } floatdiv() { return (a+c)/b; } } class m4 { public static void main(String mango[]) { object ob1 = new object(); object ob2 = new object(); object ob3 = new object(); ob1.a = 1; ob1.b = 2; ob1.c = 3; ob2.a = 4; ob2.b = 5; ob2.c = 6; ob3.a = 7; ob3.b = 8; ob3.c = 9; ob1.show(); ob2.show(); ob3.show(); int d = ob1.sum(); int e = ob1.sub(); float f = ob1.div(); int g = ob2.sum(); int h = ob2.sub(); float i = ob2.div(); int j = ob3.sum(); int k = ob3.sub(); float l = ob3.div(); System.out.println("Sum of object 1 is = " + d); System.out.println("Subtraction of object 1 is = " + e); System.out.println("Division of object 1 is = " + f); System.out.println("Sum of object 2 is = " + g); System.out.println("Subtraction of object 2 is = " + h); System.out.println("Division of object 2 is = " + i);
  • 57.
    System.out.println("Sum of object3 is = " + j); System.out.println("Subtraction of object 3 is = " + k); System.out.println("Division of object 3 is = " + l); } } class object { double name,team; String a,b; void input() { a = "orange"; b = "mango"; } void show() { a = "ABC"; b = "Super A+"; } } class m5 { public static void main(String app[]) { object pla = new object(); pla.input(); pla.show(); System.out.println("Player name is =" + pla.a); } } class object { int height; int width; } class m6 { public static void main(String app[]) { object ob1 = new object(); object ob2 = new object();
  • 58.
    ob1.height = 2; ob1.width= 3; ob2.heigth = 4; ob2.width = 5; int a = (ob1.heigth)*(ob1.width); int b = (ob2.heigth)*(ob2.width); System.out.println("Object No 1 is = " + a); System.out.println("Object No 2 is = " + b); } } class object { int width; int height; int depth; void vol() { System.out.prontln("volume is = ") ; System.out.prontln(width* height *depth); } } class m7 { public static void main(String app[]) { object ob1 = new object(); object ob2 = new object(); ob1.width = 2; ob1.height = 3; ob1.depth = 4; ob2.width = 5; ob2.height = 6; ob2.depth = 7; ob1.vol(); ob2.vol(); } } //pass by object class object { int a; int b;
  • 59.
    void pbo(object p)//Creating an object of class type { p.a = p.a + 2; p.b = p.b +3; } } class m8 { public static void main(String app[]) { object ob1 = new object(); ob1.a = 2; ob1.b = 3; System.out.println("before calling value of ob1.a = " + ob1.a); System.out.println("before calling value of ob1.b = " + ob1.b); ob1.pbo(ob1); /* p will be replaced by ob1 in method pbo*/ System.out.println("After calling value of ob1.a = "+ ob1.a); System.out.println("After calling value of ob1.b = " + ob1.b); } } // pass by value class object { void pbv(int a, int b) // method with parameter in () { a = a * 2; b = b * 3; // Only formal parameter's value will be change } } class m9 { public static void main(String app[]) { object ob1 = new object(); int c; int d; c = 4; d = 5; ob1.pbv(c,d); /* calling the function pbv and assigning the value of c, d to a, b */
  • 60.
    System.out.println("value of c= " + c); System.out.println("value of d = " + d); } } class object { String name; int roll; char sex; void set() { name = "Ali" ; roll = 1 ; sex = 'M'; } void show() //No semicolon { System.out.println("Name is = " + name); System.out.println("Roll No is = " + roll); System.out.println("Sex is = " + sex); } } class m10 { public static void main (String app[]) { object a = new object(); a.name = "ali"; // '' will replace "" a.roll = 2; // write as it is instead of a.int roll = 2; a.sex = 'M'; //"" will be replace with '' a.show(); a.set(); a.show(); } } class object { int a; int b; int c; void val()
  • 61.
    { System.out.println(" Values are= " + a + " and " + b ); } void sum() { System.out.println(" result is= " + (a + b) ); } int cal() { return a * b; } } class m11 { public static void main(String app[]) { object ob = new object(); ob.a = 2; ob.b = 3; ob.val(); ob.a = 4; ob.b = 5; ob.sum(); ob.val(); int d = ob.cal(); System.out.println(" result is= " + d); System.out.println(" result is= " + (ob.a + ob.b) ); } } class object { int a; int b; void pbo(object p) { p.a = p.a+2; p.b = p.b+3; } } class m12 { public static void main(String app[]) {
  • 62.
    object ob =new object(); ob.a = 4; ob.b = 5; System.out.println("Value of ob.a" + ob.a); ob.pbo(ob); System.out.println("Value of ob.a" + ob.a); } } // pass by value class object { void pbv(int a, int b) { a = a + 2; System.out.println("Value of a is = " + a); b = b + 3; System.out.println("Value of b is = " + b); } } class m13 { public static void main (String app[]) { object ob = new object(); int c = 4; int d = 5; ob.pbv(c,d); System.out.println("Value of c is = " + c); System.out.println("Value of d is = " + d); } } // pass by value class abc { void pbv(int a, int b, int c) { a = a + b + c; System.out.println("Value of a is = " + a); b = b + a; System.out.println("Value of b is = " + b); c = c + 2; System.out.println("Value of c is = " + c);
  • 63.
    System.out.println(" "); } } class m14 { publicstatic void main (String app[]) { abc ob = new abc(); int c = 3; int d = 4; int e = 5; ob.pbv(c,d,e); System.out.println(" "); System.out.println("Actual Value of c is = " + c); System.out.println("Actual Value of d is = " + d); System.out.println("Actual Value of e is = " + e); } } // pass by reference class obj { int a; int b; void pbo( obj p) { p.a = a + 2; p.b = b + 3; } } class m15 { public static void main (String app[]) { obj ob = new obj(); ob.a = 4; ob.b = 5; // Before calling function System.out.println("Value before call " + ob.a); System.out.println("Value before call " + ob.b); System.out.println(" "); ob.pbo(ob); System.out.println("Value after call " + ob.a); System.out.println("Value after call " + ob.b);
  • 64.
    } } // Acccess class obj { inta; int b; private int c; private void show() { System.out.println("Value of a is " + a); System.out.println("Value of b is " + b); System.out.println("Value of c is " + c); } void set(int p) { c = p; } void acc() { show(); } } class m16 { public static void main (String app[]) { obj ob = new obj(); ob.a = 2; ob.b = 3; ob.set(4); ob.acc(); } } class abc { int a; int b; int c; void set() { a = b = 0;
  • 65.
    } int set1(int p,intq) { a = p; b = q; int s; s = a * b; return s; } void multi() //void multi() { c = a * b; //c = a * b; System.out.println("Multiplication is:" + c); // System.out.println("Multiplication is:" + c); } } class ma { public static void main(String args[]) { //int ab; abc obj = new abc(intp 4,intq5); // obj.a = 10; //obj.b = 10; int d = obj.set1(); /* obj.multi(); ab=obj.set1(2,3);*/ System.out.println("Set1 is " + d); //System.out.println("Set1 is "+ ab); } } import java.awt.*; import javax.swing.*; clas abc { JButton b; JTextField t; JFrame f; void creat() { f = new JFrame("Shahzad;s Calculatetr"); Container c = f.getContentPane();
  • 66.
    c.setLayout(new FlowLayout()); t =new JTextField(20); b = new JButton("Pagal"); c.add(t); C.add(b); f.setSize(400,400); F.setVisible(true); } } clas main { public static void main(String args[]) { abc obj = new abc(); obj.creat(); } } class wq { double l; double h; void area() { System.out.println("The area is:" + (l * h)); } void perimeter() { System.out.println("Perimeter is:" + (2*l + 2*h)); } double summ() { return l*h+h; } } class main1 { public static void main(String args[]) { wq obj = new wq(); obj.l = 10; obj.h = 5; obj.area();
  • 67.
    obj.perimeter(); double d =obj.summ(); System.out.println("Sum is = " + d); } } import javax.swing.*; class math { public static void main(String args[]) { int a; int c; c = 1; String in; in = JOptionPane.showInputDialog("Enter the number:"); a = Integer.parseInt(in); while(c<=10) { System.out.println(a + "*" + c + "=" + a*c); c = c + 1; } } } class obje { int no1; int no2; obje(int n1, int n2) { no1 = n1; no2 = n2; System.out.println("value of 1st is = " + n1 + " " + n2); } obje(int n1) { System.out.println("value of 1st is = " + n1); } } class ovecon { public static void main(String app[]) {
  • 68.
    obje ob =new obje(2,3); obje ob1 = new obje(4); // ob(object should be different } } class obj { int a; int b; obj(int c, int d) { a = c; b = d; System.out.println("Value of c and d is = " + c + " " + d); } obj(int c) { System.out.println("Value of c is = " + c); } obj(int c, int d, int e) { System.out.println("Value of c, d and e is = " + c + " " + d + " " + e); } } class ovecon1 { public static void main(String app[]) { obj ob1 = new obj(4); obj ob = new obj(2,3); obj ob2 = new obj(5,6,7); } } class A { void show() { System.out.println("A"); } } class B extends A { void show()
  • 69.
    { System.out.println("B"); } } class C extendsB { void show() { System.out.println("C"); } } class over { public static void main(String args[]) { A r; r = new A(); r.show(); r = new B(); r.show(); r = new C(); r.show(); } } class math { int a=10; int b=20; void call() // Duplicate method in every class { System.out.println("a , b is = " + a + " " + b); } } class plus extends math { void call() { System.out.println("a + b is = " + (a + b)); } } class minus extends plus { void call()
  • 70.
    { System.out.println("a - bis = " + (a - b) ); } } class mul extends minus { void call() { System.out.println("a * b is = " + ( a * b)); } } class div extends mul { void call() { System.out.println("a / b is = " + (a / b)); } } class over1 { public static void main(String args[]) { math m; m = new math(); m.call(); m = new plus(); m.call(); m = new minus(); m.call(); m = new mul(); m.call(); m = new div(); m.call(); } } iyyymport javax.swing.*; class math { static a,b; String s; s=JOptionPane.showInputDialog("Enter a"); a=Integer.parseInt(s); s=JOptionPane.showInputDialog("Enter b");
  • 71.
    b=Integer.parseInt(s); void cal() { System.out.println("A andB is = " + a + " " + b); } } class plus extends math { void cal() { System.out.println("A and B is = " + (a + b)); } } class minus extends plus { void cal() { System.out.println("A and B is = " + (a - b)); } } class mul extends minus { void cal() { System.out.println("A and B is = " + (a * b)); } } class div extends mul { void cal() { System.out.println("A and B is = " + (a / b)); } } class over2 { public static void main(String args[]) { math r; r = new math(); r.cal(); } }
  • 72.
    class A { void test(inta) { System.out.println("Value of a is = " + a); } void test(int a, int b) { System.out.println("Value of a and b is = " + a +" ," + b); } void test(int a, int b, int c) { System.out.println("Value of a, b ,c is = " + a + " , " + b +" , " + c ); } } class ovmeth { public static void main(String app[]) { A ob = new A();// new or A mai space honi hai ob.test(5, 6, 7); ob.test(2); ob.test(3, 4); } } class obj { void meth() { System.out.println("No value "); } void meth(int a) { System.out.println("Value of a is = " + a); } void meth(int a, int b) { System.out.println("Value of a and b is = " + a + " " + b); } void meth(int a, int b, int c) { System.out.println("Value of a , b and c is = " + a + " " + b + " " + c);
  • 73.
    } } class ovmeth1 { public staticvoid main(String app[]) { obj ob = new obj(); ob.meth(); ob.meth(1); ob.meth(2,3); ob.meth(4,5,6); } } class pa { int a; int b; int m; void show() { int s; s = a + b; System.out.println("Sum is :" + s); } } class child extends pa { void show() { m = a * b; System.out.println("multiple is :" + m); } } class parent { public static void main(String args[]) { pa obj = new pa(); obj.a = 5; obj.b = 5; obj.show(); child obj1 = new child(); obj1.a = 4;
  • 74.
    obj1.b = 4; obj1.show(); } } importjavax.swing.*; class q { public static void main(String args[]) { int a; int b; int s; String in; in = JOptionPane.showInputDialog("Enter the number 1:"); a = Integer.parseInt(in); in = JOptionPane.showInputDialog("Enter the number 2:"); b = Integer.parseInt(in); s = a / b; System.out.println("sum is:" + s); } } import javax.swing.*; class qw { public static void main(String args[]) { int num; String in; in = JOptionPane.showInputDialog("Enter the number:"); num = Integer.parseInt(in); if(num>=85) System.out.println("Your grade is A+"); else if(num<=80 && num>75) System.out.println("Yoyr grade is A"); else if(num<=70 && num>65) System.out.println("Your grade is B"); else System.out.println("Your are fail congrats"); } }
  • 75.
    class f { int fact(intn) { if (n==1) { return 1 ; } else { return n*fact(n-1); } } } class rec { public static void main(String app[]) { f a = new f(); int r = a.fact(3); System.out.println(r); } } // recursion java program class java { // here starts a function int mul(int n) { if (n ==1) { return 1; // Body of method } else { return n*mul(n-1); } } } class rec1 { public static void main (String app[])
  • 76.
    { java f =new java(); // creating a new object naming f int a; // declare a variable a to store value of calling function a = f.mul(3); System.out.println("Factorial of no is = " + a); } } class object { int fact(int n) // semicolon nhi lagna warna return mai error { if (n==10) { return 1; } else { return n+fact(n+1); } } } class rec2 { public static void main(String app[]) { object f = new object(); int a = f.fact(1); System.out.println("Value of a is = " + a ); } } class obj { int fact(int n) { if(n==1) { return 1; } else { return n*fact(n-1); }
  • 77.
    } } class rec3 { public staticvoid main(String app[]) { obj ob = new obj(); int c = ob.fact(4); System.out.println("Value of C is = " + c); } } class obj { int a; int fact( int n) { if(n == 0) { return 1; } else { return a*a; n-1; } } } class rec4 { public static void main(String app[]) { obj ob = new obj(); ob.a = 2; int c = ob.fact(4); System.out.println("Value of c ic = " + c); } } class obj { int fact(int n) // no ; { if(n==1)
  • 78.
    { return 1; } else { return (n-1)*fact(n-1); } } } classrec5 { public static void main(String app[]) { obj ob = new obj(); int a = ob.fact(4); System.out.println(" pow is = " + a); } } class abc { int a; int b; double show() { int s; s = a + b; return s; } } class ret { public static void main(String args[]) { abc obj = new abc(); obj.a = 5; obj.b = 5; System.out.println(obj.show()); } } class math { void show() {
  • 79.
    int a =10; int b = 10; System.out.println("A and b:"+ a + " " + b); } } class plus extends math { void show() { s = a + b; System.out.println("A + B"+ s); } } class minus extends plus { void show() { int m; m = a - b; System.out.println("minus is:" + m); } } class shahzad { public static void main(String args[]) { math j; j = new math(); j = new plus(); } } import javax.swing.*; class simif { public static void main(String app[]) { int n; String o; o = JOptionPane.showInputDialog("Enter n="); n = Integer.parseInt(o); if(n % 2 == 0) System.out.println("NO is even" + n); else System.out.println("NO is odd" + n);
  • 80.
    } } import javax.swing.*; class simint2 { publicstatic void main(String app[]) { int a,b,s; String in; in = JOptionPane.showInputDialog("Enter a"); a = Integer.parseInt(in); in = JOptionPane.showInputDialog("Enter b"); b = Integer.parseInt(in); s = a + b; System.out.println("Sum is = " + s); } } import javax.swing.*; class simmul3 { public static void main(String app[]) { int a,b,s; String n; n = JOptionPane.showInputDialog("Enter a"); a = Integer.parseInt(n); n = JOptionPane.showInputDialog("Enter b"); b = Integer.parseInt(n); s = a * b; System.out.println("Product is =" + s); } } import javax.swing.*; class simmul3 { public static void main(String app[]) { int a,b,s; String n; n = JOptionPane.showInputDialog("Enter a"); a = Integer.parseInt(n); n = JOptionPane.showInputDialog("Enter b"); b = Integer.parseInt(n); s = a * b;
  • 81.
    System.out.println("Product is ="+ s); } } import javax.swing.*; class simmul4 { public static void main (String args[]) { String n; // Capital S int a,b,c,s; n = JOptionPane.showInputDialog("Enter a = "); a = Integer.parseInt(n); n = JOptionPane.showInputDialog("Enter b = "); // Capital P b = Integer.parseInt(n); n = JOptionPane.showInputDialog("Enter c = "); c = Integer.parseInt(n); s = (a * b * c); JOptionPane.showMessageDialog(null, " Product is = " + s); System.out.println(" Product is = " + s); } } import javax.swing.*; class simodev4 { public static void main(String app[]) { int n; String o; o = JOptionPane.showInputDialog("Enter n="); n = Integer.parseInt(o); if(n % 2 == 0) System.out.println("NO is even" + n); else System.out.println("NO is odd" + n); } } import java.awt.*; import java.applet.Applet; public class simpleApplet extends jApplet { public void paint(Graphics g) {
  • 82.
    g.drawString("A Simple Applet", 20, 20); } } class object { static int a; static int b; static { a = 4; b = 6; } static void show() { return "a = "+ a+ " " "b = "+ b ; System.out.println("Value of a is = " + a); System.out.println("Value of b is = " + b); } } class stat { public static void main(String app[]) { show(); } } class stat1 { static int a; static int b; static { a = 4; b = 6; } static void show() { System.out.println("Value of a is = " + a); System.out.println("Value of b is = " + b); } static void sum() { System.out.println("Sum of no is = " + (a + b)); }
  • 83.
    public static voidmain(String app[]) { show(); sum(); } } class static { static int a; static int b; static { a = 4; b = 6; } static void show() { System.out.println("Value of a is = " + a); System.out.println("Value of b is = " + b); } public static void main(String app[]) { show(); } }