Professional Documents
Culture Documents
No Program
1 W.A P. to print Simple String in java
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. to find the greatest
between three Number
8 W. A P. to given no 1 then print
“One”and 2 then print “Two” by
using switch case
9 W. A P. to Sum of two no by using
Simple & Single inheritance
10 W. A P. to Sum of two no by using
Multilevel inheritance
11 W. A P. to perform two operations
by using Hierarchical inheritance
12 W. A P. to Sum of two no in Simple
& Single inheritance and by using
command line argument
13 W. A P. to Sum of two no in
Parameterized constructor
14 W. A P. to sum of two no by using
default constructor
15 W. A P. to all operation perform in
Constructor overloading
16 W. A P. to show the method No
argument and no return
17 W. A P. to show the method with
argument no return
18 W. A P. to show the method with
argument and with return
19 W. A P. to show the method No
argument and with return
20 W. A P. show the Method
Overloading with help of command
line argument
21 W. A P. show the method overriding
22 W. A P. to the two Number Addition
and Division with the help of Super
keyword
23 W. A P. to Sum of to no in interface
program
24 W. A P. to Show the Exception
handling
25 W. A P. to input Age of preson and
find he can vote or not by using
command line argument
Program -1
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;
System.out.println(" \n sum= "+c);
System.out.println(" \n multiply= "+m);
System.out.println(" \n devision= "+d);
System.out.println(" \n subtract= "+s);
}
}
Output :-
Program-3
class commandline
{
public static void main(String[] args)
{
float a,b,s,m,d,s1;
a=Float.parseFloat(args[0]);
b=Float.parseFloat(args[1]);
s=a+b;
m=a*b;
s1=a-b;
d=a/b;
System.out.println("\n Sum="+s);
System.out.println("\n Munltiply="+m);
System.out.println("\n Subtract="+s1);
System.out.println("\n Devision="+d);
}
}
Output :-
Program-4
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=Integer.parseInt(args[0]);
for(i=1;i<=10;i++)
{
t=a*i;
System.out.println(a +"*" +i + "=" +t);
}
}
}
Program-12
class good1
{
public static void main(String[] args)
{
a=Integer.parseInt(args[0]);
b=Integer.parseInt(args[0]);
c=Integer.parseInt(args[0]);
int a=22,b=12,c=32;
if(a>b&a>c)
{
System.out.println(" a no is grates ="+a);
}
if(b>a&b>c)
{
System.out.println(" b no is greatest ="+b);
}
if(c>a&c>b)
{
System.out.println(" c no is greatest = "+c);
}
}
}
Output:-
Program-13
class hello1
{
public static void main(String[] args)
{
int a,b,c;
a=Integer.parseInt(args[0]);
switch ( a)
{
case 1:System.out.println(" One \n");break;
case 2:System.out.println(" Two \n");break;
case 3:System.out.println(" Three \n");break;
}
}
}
Output:-
Program-14
class base
{
int a=10;
}
class drived extends base
{
int b=20,c;
void sum()
{
c=a+b;
System.out.println(" \n sum="+c);
}
}
class inh1
{
public static void main(String[] args)
{
drived d=new drived();
d.sum();
}
}
Output:-
Program-15
class base
{
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;
System.out.println(" \n sum="+c);
}
}
class inh2
{
public static void main(String[] args)
{
drived d=new drived();
d.sum(); }
}
Output:-
Program-16
class base
{
int a=20;
}
class base2 extends base
{
int x=12,m;
void mult()
{
m=a*x;
System.out.println(" \n multiply="+m);
}
}
class drived extends base2
{
int b=35,c;
void sum()
{
c=a+b;
System.out.println(" \n sum="+c);
}
}
class inh3
{
public static void main(String[] args)
{
base2 b=new base2();
b.mult();
Output:-
Program-17
class hello
{
int a;
}
class good extends hello
{
int b,c;
void sum()
{
c=a+b;
System.out.println(" sum="+c);
}
}
class inhco
{
public static void main(String[] args)
{
}
}
Output:-
Program-18
class hello
{
int a,b,c;
hello(int x,int y)
{
a=x;
b=y;
}
void sum()
{
c=a+b;
System.out.println(" Sum= "+c);
}
}
class good1
{
public static void main(String[] args)
{
hello h=new hello(3,6);
h.sum();
}
}
Output:-
Program-19
class hello
{
int a,b,c;
hello()
{
a=10;
b=20;
}
void sum()
{
c=a+b;
System.out.println(" \n Sum="+c);
}
}
class good
{
public static void main(String[] args)
{
hello h=new hello();
h.sum();
}
}
Output:-
Program-20
class hello
{
float a,b,c;
hello(float k,float l )
{
a=k;
b=l;
}
void sum()
{
c=a+b;
class hello
{
int a=10,b=20,c;
void sum()
{
c=a+b;
System.out.println(" \n Sum="+c);
}
}
class sum
{
public static void main(String[] args)
{
hello h=new hello();
h.sum();
}
}
Output:-
Project-22
Output:-
Project-23
}
}
Output:-
Project-23
}
class over
{
public static void main(String[] args)
{
hello o=new hello();
o.sum();
o.mult(10,29); }
}
Output:-
Project-26
class hello
{
int a,b,c,x,y,z;
void sum(int a,int b)
{
c=a+b;
System.out.println(" \n Sum =a+b="+c);
}
void sub(int x,int y)
{
z=x+y;
System.out.println(" \n Subtraction=x+y="+z);
}
}
class overr
{
public static void main(String[] args)
{
hello h=new hello();
h.sum(20,10);
h.sub(20,5);
}
}
Output:-
Project-27
class hello
{
int a=20,b=3;
}
class drive extends hello
{
int a=10,b=27,c,d;
void sum()
{
c=a+super.a;
System.out.println(" \n Sum= a+a.super="+c);
}
void div()
{
d=b/super.b;
System.out.println(" \n Devision=
b/super.b="+d);
}
}
class main
{
public static void main(String[] args)
{
drive d=new drive();
d.sum();
d.div();
}
}
Output:-
Project-28
}
class inter
{
public static void main(String[]arg)
{
hello h;
main n=new main();
h=n;
n.sum();
}
}
Output:-
Program=29
class excep
{
public static void main(String[] args)
{
int a=2,b=0,c;
try
{
c=a/b;
System.out.println("Result="+c);
}
catch (ArithmeticException o)
{
System.out.println(" \n No can not devide by
zero");
}
}
}
Output:-
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)
{
int a;
a=Integer.parseInt(args[0]);
if(a>18)
{
System.out.println(" \n He can Vote "+a);
}
if (a<18)
{
System.out.println(" \n He can't Vpte "+a);
}
}
}
Output:-