Java Programming
About Lesson

Single inheritance can also be called as single level inheritance where parent class is known as level-0 class and child class is known as level-1 class.  If further level of inheritance is created above level -1 class, then it is called as multi level inheritance.

 

When a class is derived from another class that is already derived from another class, this is known as multi level inheritance.  In this case, one child class, its immediate parent class and parent class of its parent (grand parent class) like many levels can be seen.

 

//example showing multi level inheritance
class man{
String name=”Raju”;
float height=5.8f;

}

class husband extends man
{
String wife=”Rani”;
}

class father extends husband
{
String child=”YuvRaj”;
}

public class MultiLevelInheritanceEg {

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

System.out.println(“Name of the person: “+obj.name);
System.out.println(“Height: “+obj.height);
System.out.println(“Name of the wife: “+obj.wife);
System.out.println(“Name of the child: “+obj.child);

}

}

 

You cannot copy content of this page