In this java tutorial, we will understand the working of multi-level inheritance in java with a program example. Multi-level inheritance can be considered as a addon to single inheritance as in this type we have more than one level of inheritance (shown in the diagram below). We have a complete explanation of Inheritance in Java so if you don’t know what Inheritance in Java is then check this article out.
In multi-level Inheritance, we have a single Super Class and a subclass1(level1) which inherits the properties directly from the Super class & then we have one more subclass2(level2) which inherits the properties directly from the subclass 1 class.
public void methodA()
Class SubClass1 extends SuperClass
public void methodB()
Class SubClass2 extends SubClass1
public void methodC()
public static void main(String args)
SubClass2 obj = new SubClass2();
SubClass2.methodA(); //calling super class method
SubClass2.methodB(); //calling subclass 1 method
SubClass2.methodC(); //calling own method