Professional Documents
Culture Documents
PROGRAM #1
\\WAP to implement Method Overloading
class methodoverload
void area(int a)
int area;
area = a*a;
int area;
area = a*b;
a.area(10);
a.area(10,20);
Page 1
Tripti Agarwal 08EC58
OUTPUT:
Page 2
Tripti Agarwal 08EC58
PROGRAM #2
\\WAP to implement Method Overriding
class A
void area()
int a=10,area;
area=a*a;
class B extends A
void area()
int a=20,area;
area=a*a;
class MethodOverride
Page 3
Tripti Agarwal 08EC58
A a=new A();
B b=new B();
a.area();
b.area();
OUTPUT:
Page 4
Tripti Agarwal 08EC58
PROGRAM #3
\\WAP to implement Abstract Class & Interface
abstract class A
interface B
int c;
c = a+b;
Page 5
Tripti Agarwal 08EC58
C c = new C();
c.display();
c.add(10,20);
OUTPUT:
Page 6
Tripti Agarwal 08EC58
PROGRAM #4
\\WAP to implement Exception Handling
class ExceptHandling
try
c=a/b;
catch(Exception e)
System.out.println("Exception is cought");
finally
Page 7
Tripti Agarwal 08EC58
OUTPUT:
Page 8
Tripti Agarwal 08EC58
Page 9
Tripti Agarwal 08EC58
Page 10
Tripti Agarwal 08EC58
PROGRAM #6
\\WAP to implement Socket Programming using Simple Server\Client.
import java.net.*;
import java.io.*;
InputStream s1In=s1.getInputStream();
System.out.println(st);
dis.close();
s1In.close();
s1.close();
OUTPUT:
Page 11
Tripti Agarwal 08EC58
import java.net.*;
import java.io.*;
Socket s1=s.accept();
OutputStream s1out=s1.getOutputStream();
dos.writeUTF("Hi There");
dos.close();
s1out.close();
s1.close();
OUTPUT:
Page 12
Tripti Agarwal 08EC58
PROGRAM #7
\\ WAP to display the IP address of the system.
import java.lang.*;
import java.net.*;
try{
InetAddress ownIP=InetAddress.getLocalHost();
Page 13
Tripti Agarwal 08EC58
Page 14
Tripti Agarwal 08EC58
Page 15
Tripti Agarwal 08EC58
Page 16
Tripti Agarwal 08EC58
Page 17
Tripti Agarwal 08EC58
Page 18