List Of Programs (Advance Java)



Manav Rachna College of Engineering

Advance Java Lab Manual

Submitted By:-

Kirti Aggarwal

List Of Programs (Advance Java)

1. WAP to swap two numbers without using third variable.

2. WAP to check whether a number is Armstrong or not.

3. WAP to implement the Concept of Function Overloading.

4. WAP to implement the Concept of Function Overriding.

5. WAP to implement the Exceptional Handling.

6. WAP of an applet that receives two numerical values as the input from user and displays the sum of these two numbers.

7. WAP for displaying product list along with their prices and then allow user to buy any1 item from them with required quantity.

8. WAP to implement multithreading(three threads using single run method).

9. WAP to implement the calculator.

10. WAP to implement the URL.

11. WAP to implement the InetAddress.

12. WAP for Sending e-mail in Java.

13. WAP to implement Single Client-Server Communication.

14. WAP to implement the Login_Id Form using JDBC.

15. WAP to implement the SQL commands using JDBC.

16. WAP to implement the List.

17. WAP to implement the JTrees.

18. WAP to implement the JTable.

19. WAP to create the table using JDBC.

20. WAP to implement Remote Method Invocation.

Program:-1

WAP for swapping of two numbers.

package swap;

import java.util.*;

public class Main

{

public static void main(String[] args)

{

int a,b;

System.out.println("Enter the two numbers: ");

Scanner s= new Scanner(System.in);

a = s.nextInt();

b = s.nextInt();

System.out.println("Number before swapping:" +a+" " +b);

a=a+b;

b=a-b;

a=a-b;

System.out.println("Number after swapping:" +a+" " +b);

}

}

OUTPUT

Enter the two numbers:

34 56

Number before swapping:34 56

Number after swapping:56 34

Program:-2

WAP to find whether number is Armstrong or not.

package armstrng;

import java.util.*;

public class ARMSTRONG

{

public static void main(String[] args)

{

int a,r,b=0;

System.out.println("Enter the number: ");

Scanner s= new Scanner(System.in);

a = s.nextInt();

int n=a;

while(a>0)

{

r=a%10;

a=a/10;

b= b + (r*r*r);

}

if(n==b)

{

System.out.println("Number is Armstrong");

}

Else

{

System.out.println("Not Armstrong");

}

}

}

OUTPUT

Enter the number:

153

Number is Armstrong

Enter the number:

234

Not Armstrong

Program:-3

WAP to implement the concept of function overloading.

package funcover;

import java.util.*;

class Main

{

void Area()

{

int r=5;

System.out.println("Area of circle with no argument: "

+(3.14*r*r));

}

void Area(int r)

{

System.out.println("Area of circle: " +(3.14*r*r));

}

void Area(int a,int b)

{

System.out.println("Area of rectangle: " +(a*b));

}

void Area(float a,float b)

{

System.out.println("Area of rectangle: " +(a*b));

}

}

public class func_overloading

{

public static void main(String[] args)

{

Main m=new Main();

Int a,b;

System.out.println("Enter the two numbers: ");

Scanner s= new Scanner(System.in);

a = s.nextInt();

b = s.nextInt();

m.Area();

m.Area(a);

m.Area(a,b);

m.Area(5.5f,6.5f);

}

}

OUTPUT

Enter the two numbers: 7 6

Area of circle with no argument: 78.5

Area of circle: 153.86

Area of rectangle: 42

Area of rectangle: 35.75

Program:-4

WAP to implement function overriding.

package funcoverr;

class A

{

void show()

{

System.out.println("welcome to class A");

}

}

class B extends A

{

void show()

{

super.show();

System.out.println("welcome to class B");

super.show();

}

}

public class func_overriding

{

public static void main(String[] args)

{

B b=new B();

b.show();

}

}

OUTPUT

welcome to class A

welcome to class B

welcome to class A

Program:-5

WAP to implement the Exceptional Handling.

package excptnhng;

import java.util.*;

public class Main

{

public static void main(String[] args)

{

try

{ int c[]={1,2};

c[3]=10;

}

catch(ArrayIndexOutOfBoundsException e)

{

System.out.println("Array out of bound");

}

try

{

int a=3;

int b;

System.out.println(“Enter the no.”);

Scanner s=new Scanner(System.in);

b=s.nextInt();

int d=a/b;

}

catch(ArithmeticException e)

{ System.out.println("divide by zero");

}

Finally

{ System.out.println("welcome");

}}}

OUTPUT

Array out of bound

Enter the no. 3

Welcome

Program:-6

WAP of an applet that receives two numerical values as the input from user and displays the sum of these two numbers.

package javaapplication6;

import java.applet.Applet;

import java.awt.*;

public class NewApplet extends Applet

{

TextField t1,t2;

public void init()

{

t1=new TextField(8);

t2=new TextField(8);

add(t1);

add(t2);

t1.setText("0");

t2.setText("0");

}

public void paint (Graphics g)

{ int a,b;

a=Integer.parseInt(t1.getText());

b=Integer.parseInt(t2.getText());

int c=a+b;

String s=Integer.toString(c);

g.drawString("the sum is",20,30);

g.drawString(s,50,50);

}}

OUTPUT

[pic]

Program:-7

WAP for displaying product list along with their prices and then allow user to buy any1 item from them with required quantity.

package product_list;

import java.util.*;

public class Main

{

int price[] = new int[5];

String name[] = new String[5];

String g="";

int d;

int f;

int h;

public void items()

{

for(int j=0;j ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download