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.
Sandhya Answered question September 7, 2023
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.
Vishalini.R Answered question September 7, 2023