Inheritance in Java is the method to create a hierarchy between classes by inheriting from other classes. Java Inheritance is transitive – so if Sedan extends Car and Car extends Vehicle, then Sedan is also inherited from the Vehicle class. The Vehicle becomes the superclass of both Car and Sedan.
By deriving from other classes, Java’s inheritance mechanism allows classes to be nested one above the other. Java inheritance is transitive, therefore if Sedan extends Car and Car extends Vehicle, then Sedan also derives from the Vehicle class. The vehicle becomes the superclass for both cars and sedans.