0% found this document useful (0 votes)
20 views4 pages

Kalpesh 9

Uploaded by

KALPESH BORSE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views4 pages

Kalpesh 9

Uploaded by

KALPESH BORSE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

JAVA PRACTICAL 2106025

Program 1:- Program for implementing single inheritance:-

class animal{ //2106025


String name;

public void abc()


{
System.out.println("Dog : "+name);
}

class cat extends animal{


int cat=210;

public void xyz()


{
System.out.println(cat);
}
}

public class emp {

public static void main(String[] args)


{
cat aa=new cat();
aa.name="German";
aa.abc();
aa.xyz();
}
}

OUTPUT:-

1
JAVA PRACTICAL 2106025

Program 2 :- Program for implementing multiple inheritance:-

interface A { //2106025
void methodA();
}

interface B {
void methodB();
}

class MultipleInheritanceClass implements A, B {


@Override
public void methodA() {
System.out.println("Method A is called.");
}

@Override
public void methodB() {
System.out.println("Method B is called.");
}
}

public class multiple {


public static void main(String[] args) {
MultipleInheritanceClass obj = new MultipleInheritanceClass();

obj.methodA();
obj.methodB();
}
}

OUTPUT:-

2
JAVA PRACTICAL 2106025

Program 3:- Program for implementing multilevel inheritance:-

class principal //2106025


{
String name="I'm the Principal";
void top()
{
System.out.println(name);
}
}

class Hod extends principal


{
String name="I'm the HOD";
void top2()
{
System.out.println(name);
}
}

class teacher extends Hod


{
String name="I'm the Teacher";
void top3()
{
System.out.println(name);
}
}

public class multilevel {

public static void main(String[] args)


{
Hod aa=new Hod();
teacher bb=new teacher();

aa.top();
bb.top2();

}
}

3
JAVA PRACTICAL 2106025

OUTPUT:-

You might also like