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.
This Java program demonstrates the concept of multilevel inheritance, where a derived class extends another derived class which itself extends a base class.
//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 multilevel { public static void main(String args[]) { son o = new son(); o.car(); o.house(); o.land(); } }
Own Audi Car.. 3 BHK House. 5 Arcs of Land..To download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions