INDEX
[Link] Program Page No Sing.
1 W.A P. to print Simple String in java 3
2 W.A P. to perform All operations in Java
3 W.A P. to we may perform All operations in
Java by using command line argument
4 W.A P. to find the Area of Circle in java
5 W.A.P. to find the Percentage of any class
6 W.A P. to print any No. of Table
7 W. A P. program to print 1 to 10 numbers
8 W. A P. to print 10 to 1 reverse numbers
9 W. A P. to print even number from 1 to 20
10 W. A P. to print Odd number from 1 to 20
11 W. A P. to print 10 time welcome
12 W. A P. to find the greatest between three
Number
13 W. A P. to given no 1 then print “One”and 2
then print “Two” by using switch case
14 W. A P. to Sum of two no by using Simple
& Single inheritance
1 Munish kumar Vth Sem 20181301
15 W. A P. to Sum of two no by using
Multilevel inheritance
16 W. A P. to perform two operations by using
Hierarchical inheritance
17 W. A P. to Sum of two no in Simple &
Single inheritance and by using command
line argument
18 W. A P. to Sum of two no in Parameterized
constructor
19 W. A P. to sum of two no by using default
constructor
20 W. A P. to all operation perform in
Constructor overloading
21 W. A P. to show the method No argument
and no return
22 W. A P. to show the method with
argument no return
23 W. A P. to show the method with
argument and with return
24 W. A P. to show the method No argument
and with return
25 W. A P. show the Method Overloading
with help of command line argument
2 Munish kumar Vth Sem 20181301
26 W. A P. show the method overriding
27 W. A P. to the two Number Addition and
Division with the help of Super keyword
28 W. A P. to Sum of to no in interface
program
29 W. A P. to Show the Exception handling
30 W. A P. to input Age of preson and find he
can vote or not by using command line
argument
31 Draw a house to program in java applet
32 Draw a Computer Diagram program in java
applet
33
3 Munish kumar Vth Sem 20181301
Program -1
# Write a program to print Simple String in java
class simple
{
public static void main(String[] args)
{
[Link](" \n ****** Welcome to Jamuna
Prasad Memorial College Bareilly ******* ");
}
}
Output:-
4 Munish kumar Vth Sem 20181301
Program-2
# Write a program we may perform All operations in Java
Class alloperations
{
public static void main(String[] args)
{
int a=10,b=20,c,m,d,s;
c=a+b;
m=a*b;
d=a/b;
s=a-b;
[Link](" \n sum= "+c);
[Link](" \n multiply= "+m);
[Link](" \n devision= "+d);
[Link](" \n subtract= "+s);
}
}
5 Munish kumar Vth Sem 20181301
Output :-
6 Munish kumar Vth Sem 20181301
Program-3
# Write a program we may perform All operations in Java
with the help of Command line argument
class commandline
{
public static void main(String[] args)
{
float a,b,s,m,d,s1;
a=[Link](args[0]);
b=[Link](args[1]);
s=a+b;
m=a*b;
s1=a-b;
d=a/b;
[Link]("\n Sum="+s);
[Link]("\n Munltiply="+m);
[Link]("\n Subtract="+s1);
[Link]("\n Devision="+d);
7 Munish kumar Vth Sem 20181301
}
}
Output :-
8 Munish kumar Vth Sem 20181301
Program-4
# Writ a program to find the Area of Circle in java
class area
{
public static void main(String[] args)
{
Float r,b,a;
r=[Link](args[0]);
b=[Link](args[1]);
a=r*r*b;
[Link](" \n Area of Circle = "+a);
}
}
9 Munish kumar Vth Sem 20181301
Output:-
10 Munish kumar Vth Sem 20181301
Program-5
# Writ a program to find the Percentage of any class with the
help of command line argument in java.
Class percentage
{
public static void main(String[] args)
{
int h,e,p,c,m,t,pr;
h=[Link](args[0]);
e=[Link](args[1]);
p=[Link](args[2]);
c=[Link](args[3]);
m=[Link](args[4]);
t=h+e+p+c+m;
pr=(h+e+p+c+m)*100/500;
[Link]("Total Numbers in Inter Class =
"+t);
[Link]("Total Persentage in Inter Class =
"+p);
11 Munish kumar Vth Sem 20181301
}
}
Outout;-
12 Munish kumar Vth Sem 20181301
Program -6
# -Write a program to print any No. of Table with the help of
command line argument in java
class table2
{
public static void main(String[] args)
{
int a,i,t;
a=[Link](args[0]);
for(i=1;i<=10;i++)
{
t=a*i;
13 Munish kumar Vth Sem 20181301
[Link](a +"*" +i + "=" +t);
}
}
}
Output:-
14 Munish kumar Vth Sem 20181301
Program-7
# - Write a program to print 1 to 10 numbers
class ten
{
public static void main(String[] args)
{
int i;
for(i=1;i<=10;i++)
{
[Link]("\n "+i);
}
15 Munish kumar Vth Sem 20181301
}
}
Output:-
16 Munish kumar Vth Sem 20181301
Program-8
#-Write a program to print 10 to 1 numbers
class tenr
{
public static void main(String[] args)
{
int i;
for(i=10;i>=1;i--)
{
[Link]("\n "+i);
17 Munish kumar Vth Sem 20181301
}
}
}
Output:-
18 Munish kumar Vth Sem 20181301
Program-9
#-Write a program to print even number from 1 t0 20
class even
{
public static void main(String[] args)
{
int i;
for (i=2;i<=20 ;i=i+2 )
{
[Link]("\n Even No.= "+i);
}
}
19 Munish kumar Vth Sem 20181301
}
Output:-
20 Munish kumar Vth Sem 20181301
Program-10
#-Write a program to print Odd number from 1 t0 20
class odd
{
public static void main(String[] args)
{
int i;
for (i=1;i<=20 ;i=i+2 )
{
[Link](" \n Odd No= "+i);
}
}
21 Munish kumar Vth Sem 20181301
}
Output:-
22 Munish kumar Vth Sem 20181301
Program-11
#-Write a program to print 10 time welcome
class wel
{
public static void main(String[] args)
{
int i;
for (i=1;i<=10;i++ )
{
[Link](" \n Welcome");
}
23 Munish kumar Vth Sem 20181301
}
}
Output:-
24 Munish kumar Vth Sem 20181301
Program-12
#-Write a program to find the greatest between three no in
java
class good1
{
public static void main(String[] args)
{
a=[Link](args[0]);
b=[Link](args[0]);
c=[Link](args[0]);
int a=22,b=12,c=32;
25 Munish kumar Vth Sem 20181301
if(a>b&a>c)
{
[Link](" a no is grates ="+a);
}
if(b>a&b>c)
{
[Link](" b no is greatest
="+b);
}
if(c>a&c>b)
{
[Link](" c no is greatest = "+c);
}
}
}
Output:-
26 Munish kumar Vth Sem 20181301
Program-13
# - Write a program given no 1 then print “One ”and 2 then
pint “Two” by using switch case in java
class hello1
{
public static void main(String[] args)
{
int a,b,c;
27 Munish kumar Vth Sem 20181301
a=[Link](args[0]);
switch ( a)
{
case 1:[Link](" One \n");break;
case 2:[Link](" Two \n");break;
case 3:[Link](" Three \n");break;
}
}
Output:-
28 Munish kumar Vth Sem 20181301
Program-14
#-Write a program Sum of two no by using Simple & Single
inheritance in java
29 Munish kumar Vth Sem 20181301
class base
{
int a=10;
}
class drived extends base
{
int b=20,c;
void sum()
{
c=a+b;
[Link](" \n sum="+c);
}
}
class inh1
{
public static void main(String[] args)
{
drived d=new drived();
[Link]();
30 Munish kumar Vth Sem 20181301
}
}
Output:-
Program-15
#-Write a program Sum of two no by using Multilevel
inheritance in java
class base
31 Munish kumar Vth Sem 20181301
{
int a=10;
}
class base2 extends base
{
int x=12,m;
}
class drived extends base2
{
int b=20,c;
void sum()
{
c=a+b*x;
[Link](" \n sum="+c);
}
}
class inh2
{
public static void main(String[] args)
32 Munish kumar Vth Sem 20181301
{
drived d=new drived();
[Link]();
}
}
Output:-
33 Munish kumar Vth Sem 20181301
Program-16
34 Munish kumar Vth Sem 20181301
#-Write a program to we may perform two operations by
using Hierarchical inheritance in java
class base
{
int a=20;
}
class base2 extends base
{
int x=12,m;
void mult()
{
m=a*x;
[Link](" \n multiply="+m);
}
}
class drived extends base2
{
35 Munish kumar Vth Sem 20181301
int b=35,c;
void sum()
{
c=a+b;
[Link](" \n sum="+c);
}
}
class inh3
{
public static void main(String[] args)
{
base2 b=new base2();
[Link]();
drived d=new drived();
[Link]();
}
}
Output:-
36 Munish kumar Vth Sem 20181301
Program-17
37 Munish kumar Vth Sem 20181301
#-Write a program Sum of two no by using Simple & Single
inheritance and with the help f command line argument in
java
class hello
{
int a;
}
class good extends hello
{
int b,c;
void sum()
{
c=a+b;
[Link](" sum="+c);
}
}
class inhco
38 Munish kumar Vth Sem 20181301
{
public static void main(String[] args)
{
hello h=new hello();
good o=new good();
o.a=[Link](args[0]);
o.b=[Link](args[1]);
[Link]();
}
}
Output:-
39 Munish kumar Vth Sem 20181301
Program-18
40 Munish kumar Vth Sem 20181301
#-Write a program two no addition Parameterized
constructor
class hello
{
int a,b,c;
hello(int x,int y)
{
a=x;
b=y;
}
void sum()
{
c=a+b;
[Link](" Sum= "+c);
}
}
class good1
41 Munish kumar Vth Sem 20181301
{
public static void main(String[] args)
{
hello h=new hello(3,6);
[Link]();
}
}
Output:-
Program-19
42 Munish kumar Vth Sem 20181301
#-Write a program sum of two no by using default constructor
in java
class hello
{
int a,b,c;
hello()
{
a=10;
b=20;
}
void sum()
{
c=a+b;
[Link](" \n Sum="+c);
}
}
class good
{
43 Munish kumar Vth Sem 20181301
public static void main(String[] args)
{
hello h=new hello();
[Link]();
}
}
Output:-
Program-20
44 Munish kumar Vth Sem 20181301
#-Write a program all operation perform in Constructor
overloading
class hello
{
float a,b,c;
hello(float k,float l )
{
a=k;
b=l;
}
void sum()
{
c=a+b;
[Link]("\n Sum= "+c);
}
void sub()
{
45 Munish kumar Vth Sem 20181301
c=a-b;
[Link]("\n Sub= "+c);
}
void multi()
{
c=a*b;
[Link]("\n Multiply= "+c);
}
void devi()
{
c=a/b;
[Link]("\n Division= "+c);
}
}
class good2
{
public static void main(String[] args)
{
hello h=new hello(14,10);
[Link]();
46 Munish kumar Vth Sem 20181301
[Link]();
[Link]();
[Link]();
}
}
Output:-
Project-21
47 Munish kumar Vth Sem 20181301
#- Write a program to show the method No argument and no
return
class hello
{
int a=10,b=20,c;
void sum()
{
c=a+b;
[Link](" \n Sum="+c);
}
}
class sum
{
public static void main(String[] args)
{
hello h=new hello();
[Link]();
}
48 Munish kumar Vth Sem 20181301
}
Output:-
Project-22
49 Munish kumar Vth Sem 20181301
#-Write a program to show the method with argument no
return
class hello
{
int a,b,c;
void sum( int a,int b)
{
c= a+b;
[Link](" \n Sum="+c);
}
}
class sum2
{
public static void main(String[] args)
{
hello h=new hello();
[Link](20,30);
}
}
50 Munish kumar Vth Sem 20181301
Output:-
Project-23
51 Munish kumar Vth Sem 20181301
#-Write a program to show the method with argument and
with return
class hello
{
int a,b,c;
int sum( int a,int b)
{
c= a+b;
return (c);
}
}
class sum3
{
public static void main(String[] args)
{
int s;
hello h=new hello();
s=[Link](20,30);
52 Munish kumar Vth Sem 20181301
[Link]("\n Sum="+s);
}
}
Output:-
Project-23
53 Munish kumar Vth Sem 20181301
#-Write a program show the method No argument and with
return
class hello
{
int a=10,b=20,c;
int sum()
{
c=a+b;
return (c);
}
}
class sum1
{
public static void main(String[] args)
{
hello o=new hello();
int s;
s=[Link]();
[Link](" \n Sum="+s);
54 Munish kumar Vth Sem 20181301
}
}
Output:-
Projetc-25
55 Munish kumar Vth Sem 20181301
#-Write a program show the Method Overloading with help
of command line argument
class hello
{
int a=20,b=30,c,x,y,z;
void sum()
{
c=a+b;
[Link](" \n Sum = a+b = "+c);
}
void mult(int x,int y)
{
z=x*y;
[Link](" \n Multiply = x*y= "+z);
}
}
class over
{
56 Munish kumar Vth Sem 20181301
public static void main(String[] args)
{
hello o=new hello();
[Link]();
[Link](10,29); }
}
Output:-
Project-26
57 Munish kumar Vth Sem 20181301
#-Write a program show the method overriding
class hello
{
int a,b,c,x,y,z;
void sum(int a,int b)
{
c=a+b;
[Link](" \n Sum =a+b="+c);
}
void sub(int x,int y)
{
z=x+y;
[Link](" \n Subtraction=x+y="+z);
}
}
class overr
{
public static void main(String[] args)
58 Munish kumar Vth Sem 20181301
{
hello h=new hello();
[Link](20,10);
[Link](20,5);
}
}
Output:-
Project-27
59 Munish kumar Vth Sem 20181301
#-Write a program to the two Number Addition and Division
with the help of Super keyword
class hello
{
int a=20,b=3;
}
class drive extends hello
{
int a=10,b=27,c,d;
void sum()
{
c=a+super.a;
[Link](" \n Sum= a+[Link]="+c);
}
void div()
{
d=b/super.b;
[Link](" \n Devision=
b/super.b="+d);
60 Munish kumar Vth Sem 20181301
}
}
class main
{
public static void main(String[] args)
{
drive d=new drive();
[Link]();
[Link]();
}
}
Output:-
61 Munish kumar Vth Sem 20181301
Project-28
#-Write a program to all operation perform in interface
program with the help of command line argument
62 Munish kumar Vth Sem 20181301
interface hello
{
int a=20,b=34;
}
class main implements hello
{
int s;
void sum()
{
s=a+b;
[Link](" \n Sum= a+b ="+s);
}
}
class inter
{
public static void main(String[]arg)
{
hello h;
main n=new main();
63 Munish kumar Vth Sem 20181301
h=n;
[Link]();
}
}
Output:-
Program=29
#- Write a program to show the exception handling
class excep
{
public static void main(String[] args)
64 Munish kumar Vth Sem 20181301
{
int a=2,b=0,c;
try
{
c=a/b;
[Link]("Result="+c);
}
catch (ArithmeticException o)
{
[Link](" \n No can not devide by
zero");
}
}
}
Output:-
65 Munish kumar Vth Sem 20181301
Program-30
#- Write a program to input Age of person and find he can
vote or not by using command line argument
class vote
{
public static void main(String[] args)
{
66 Munish kumar Vth Sem 20181301
int a;
a=[Link](args[0]);
if(a>18)
{
[Link](" \n He can Vote "+a);
}
if (a<18)
{
[Link](" \n He can't Vpte "+a);
}
}
}
Output:-
67 Munish kumar Vth Sem 20181301
Program-31
#-Draw a house to program in java applet
//<applet code="[Link]" height=1300
width=1300></applet>
import [Link].*;
import [Link].*;
68 Munish kumar Vth Sem 20181301
public class apple1 extends Applet
{
Font f = new
[Link]("TimesRoman",[Link],36);
Font f1 = new [Link]("Arial",[Link],26);
Font f2 = new
[Link]("MonotypeCorsiva",[Link],16);
public void paint(Graphics g)
{
[Link](f);
[Link]("This is My First Program In Java
Applet ",100,50);
//setBackground([Link]);
setForeground([Link]);
[Link](20,250,250,80);
[Link](480,250,250,80);
[Link]([Link]);
69 Munish kumar Vth Sem 20181301
[Link](120,180,260,250);
[Link]([Link]);
[Link](180,280,150,150);
[Link]([Link]);
[Link](210,95,80,80);
}
}
Output:-
70 Munish kumar Vth Sem 20181301
Project-32
#-Draw a Computer Diagram program in java applet
//<applet code="[Link]" height=600
width=600></applet>
71 Munish kumar Vth Sem 20181301
import [Link].*;
import [Link].*;
public class computer extends Applet
{
Font f=new [Link]("times Roman",[Link],37);
Font f2=new [Link]("times
Roman",[Link],20);
public void paint (Graphics g)
{
[Link](f2);
setForeground([Link]);
[Link]([Link]);
[Link](150,80,190,190);
[Link]([Link]);
[Link](170,100,150,150);
[Link]([Link]);
72 Munish kumar Vth Sem 20181301
[Link]("Cmputer Diagram",230,50);
[Link]("Welcome Sir",180,120);
[Link]("My Name is",180,140);
[Link]("Munish Kumar",180,160);
[Link]("Applet Java",180,180);
[Link]("This is My ",180,200);
[Link]("First Programe",180,220);
[Link]([Link]);
[Link](240,250,10,50);
[Link]([Link]);
[Link](205,300,80,20);
[Link]([Link]);
[Link](190,330,100,40);
[Link]([Link]);
[Link](195,335,7,7);
[Link](205,335,7,7);
73 Munish kumar Vth Sem 20181301
[Link](215,335,7,7);
[Link](225,335,7,7);
[Link](235,335,7,7);
[Link](245,335,7,7);
[Link](255,335,7,7);
[Link](265,335,7,7);
[Link](275,335,7,7);
[Link](195,345,7,7);
[Link](205,345,7,7);
[Link](215,345,7,7);
[Link](225,345,7,7);
[Link](235,345,7,7);
[Link](245,345,7,7);
[Link](255,345,7,7);
[Link](265,345,7,7);
[Link](275,345,7,7);
[Link](195,355,7,7);
[Link](205,355,7,7);
[Link](215,355,7,7);
[Link](225,355,7,7);
74 Munish kumar Vth Sem 20181301
[Link](235,355,7,7);
[Link](245,355,7,7);
[Link](255,355,7,7);
[Link](265,355,7,7);
[Link](275,355,7,7);
[Link]([Link]);
[Link](350,220,70,150);
[Link]([Link]);
[Link](360,230,50,30);
[Link]([Link]);
[Link](380,235,10,10);
[Link]([Link]);
[Link](360,300,10,10);
[Link](380,300,10,10);
[Link](400,300,10,10);
75 Munish kumar Vth Sem 20181301
[Link]([Link]);
[Link](350,340,70,20);
[Link]([Link]);
[Link](250,265,350,280);
[Link](250,330,350,300);
[Link](450,150,70,50);
[Link]([Link]);
[Link](460,160,30,35);
[Link]([Link]);
[Link](472,165,8,8);
[Link](468,177,5,5);
[Link](480,178,5,5);
[Link]([Link]);
[Link](500,165,15,20);
[Link](450,170,420,250);
76 Munish kumar Vth Sem 20181301
}
}
Output:-
77 Munish kumar Vth Sem 20181301
78 Munish kumar Vth Sem 20181301