Multilevel Inheritance Example
Multilevel Inheritance Example
In this example we have three classes – Car, Maruti and Maruti800. We have done a setup – class
Maruti extends Car and class Maruti800 extends Maruti. With the help of this Multilevel hierarchy
setup our Maruti800 class is able to use the methods of both the classes (Car and Maruti).
class Car{
public Car()
System.out.println("Class Car");
public Maruti()
System.out.println("Class Maruti");
System.out.println("Brand: Maruti");
System.out.println("Max: 90Kmph");
public Maruti800()
{
System.out.println("Maruti Model: 800");
System.out.println("Max: 80Kmph");
obj.vehicleType();
obj.brand();
obj.speed();
Output:
Class Car
Class Maruti
Brand: Maruti
Max: 80Kmph