Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

Practical No 10.

➢ Develop Program for Implementation of Multilevel


Constructors in the Class.
Program:-

class NumberValue
{

private int num; public NumberValue(


{

num = 6;
}

public NumberValue(int n)
{

num = n;

public void display()

{
System.out.println("The number is: " + num);
}

public class Demo


{

public static void main(String[] args)


{

NumberValue obj1 = new

NumberValue();
NumberValue obj2 = new

NumberValue(15);

obj1.display();

obj2.display();

***********************************************************

OUTPUT:-
Practical No 13. Develop a Program for Implementation
Array .Program:-

class Test array


{
public static void main(String args[])
{
int arr[][]={{2,1,5},{8,7,3},{25,11, 1}};
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
System.out.print(arr[i][j]+" ");
}
System.out.println();
}

}
}
OUTPUT:-
Practical No 14. Develop a Program for Implementation
Vector. Program:-
import

java.util.Vector;
class Main
{
public static void main(String[] args)
{
Vector<String> student= new

Vector<>(); student.add("SUNIL");
student.add("ANIL");

student.add("SAI");

System.out.println("Initial Vector: " + student);

String element = student.remove(1);

System.out.println("Removed Element: " +


element);

System.out.println("New Vector: " +student);


student.clear();

System.out.println("Vector after clear(): " +student);

}
OUTPUT:-
Practical No 15 .
➢ Develop a Program for Implementation of Wrapper Class to
Primitive into Object
Program:-
public class
WrapperExample1

public static void


main(String args[])

int a=80;
Integer
i=Integer.valueOf(a);
Integer j=a;
System.out.println(a+"
"+i+" "+j);
}
}
OUTPUT:-
Practical 16.
➢ Wrapper Class to Object into Primitive.
Program:-

public class WrapperExample2


{

public static void main(String args[])

Integer a=new Integer(9);

int i=a.intValue();

int j=a;

System.out.println(a+" "+i+" "+j);

***********************************************************

OUTPUT
Practical No 17.
➢ Develop a Program Which Implement the Concept of
overriding.
Program:-

class Principal
{

public void displayInfo()

System.out.println("I am Principal.");

}
}

class Teacher extends Principal


{

public void displayInfo()

super.displayInfo();

System.out.println("I am Teacher");

}
}

class Student extends Teacher


{
public void displayInfo()

super.displayInfo();

System.out.println("I am Student");
}
}
class Main

{
public static void main(String[] args)

{
Student s = new Student();

s.displayInfo();

s.displayInfo();

}
*********************************************

OUTPUT:-
Practical No 18.
➢ Develop a Program for Implementation Single Inheritance.
Program:-

class Manager
{

void profit()

System.out.println("PROFIT");

class Employee extends Manager

void loss()

System.out.println("LOSS");

class TestInheritance

public static void main(String args[])

{
Employee e=new Employee();

e.profit();

e.loss();

***********************************************************
OUTPUT:-
Practical No 18.
➢ Develop a Program for Implementation Multilevel
Inheritance.
Program:-
class Painter
{

void paint()
{

System.out.println("PAINT");

class Teacher extends Painter


{

void teach()
{

System.out.println("TEACHING");
}

}
class Writer extends Teacher
{

void writ()
{

System.out.println("WRITING");
}

class TestInheritance
{
public static void main(String args[])

Writer w=new Writer();

w.Paint();

w.teach();

w.writ();

****************************************************
OUTPUT:-
Practical No 19.
➢ Develop a Program for Implementation Multiple
Inheritance.
Program:-

interface Event
{

public void start();


}

interface Cricket
{

public void play();


}

interface Badminton extends Cricket, Event


{

public void show();


}

public class Tester


{

public static void main(String[] args)


{

Badminton badminton = new Badminton()


{

public void start()


{

System.out.println("Start Event");
}

public void play()


{
System.out.println("Play Sports");
}

public void show()


{

System.out.println("Show Badminton");
}

};
badminton.start();

badminton.play();

badminton.show();

}
}

OUTPUT:-

You might also like