Multilevel Inheritance in Java
Multilevel inheritance is simply a chain of extends relationships more than one level deep — class C extends B, and class B extends A, makes C inherit from B, which itself inherits from A, so C ends up with everything both B and A define, combined. Each class in the chain only needs to declare extends for its own direct superclass; Java resolves the rest of the chain automatically, so C never has to mention A by name at all to inherit from it indirectly.
A constructor chain runs the same way — creating a C object calls C's constructor, whose first action, an explicit super(...) or an implicit no-argument call, invokes B's constructor, which in turn calls A's. So the very top of the chain always finishes initializing first, before any class further down adds its own part.
A chain of extends
class C extends B extends A creates three levels, each inheriting from the one directly above it.
Indirect inheritance
C automatically has everything A defines too, without ever writing extends A directly.
Each class declares only its direct superclass
Java resolves the rest of a multilevel chain on its own.
Constructor chaining runs top to bottom
Creating the most specific class's object still initializes the topmost superclass first, then each level down in order.
Every level can add its own fields and methods
On top of everything inherited from further up the chain.
class Animal { void breathe() { System.out.println("Breathing"); }} class Mammal extends Animal { void nurse() { System.out.println("Nursing young"); }} public class Dog extends Mammal { public static void main(String[] args) { Dog rex = new Dog(); rex.breathe(); rex.nurse(); }}Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Practice what you learned
Re-implement each visualized algorithm in Java yourself — building beats watching.