Multilevel Inheritance in Java

Inheritance in Java is a mechanism in which one object acquires all the properties and behaviors of a parent object. It is an important part of OOPs (Object Oriented programming system). When a class extends a class, which extends anther class then this is called multilevel inheritance.

Example : class Son extends class Father and class Father extends class Grandfather then this type of inheritance is known as multilevel inheritance.

Code Snippet

// Multilevel Inheritance in Java
class GrandFather {
    public void house() {
        System.out.println("3 BHK House.");
    }
}

class father extends GrandFather {
    public void land() {
        System.out.println("5 Arcs of Land..");
    }
}

class son extends father {
    public void car() {
        System.out.println("Own Audi Car..");
    }
}

public class App {
    public static void main(String args[]) {
        son o = new son();
        o.car();
        o.house();
        o.land();
    }
}