KnowledgeBoat Logo

Computer Applications

Define the following with an example each:

Inheritance

OOP Intro Java

63 Likes

Answer

Inheritance is a property by virtue of which one class acquires some features from another class. It promotes reusability.

As an example of inheritance, we can consider the case of vehicles. All vehicles have some common features like they can move on the road and transport people and goods from one place to another. These vehicles differ from each other in certain aspects like whether it transports passengers or goods, how many passengers it can accommodate at a time, whether it is a two-wheeler or four-wheeler, etc. So, we have different types of vehicles like Cars, Bikes, Scooters, Auto rickshaw, Buses, Trucks, etc. Using inheritance, we can make vehicles the base class with the different types of vehicles being the derived class as shown below:

ICSE Logix class 10 solutions Vehicle class hierarchy as example of Inheritance

Answered By

34 Likes


Related Questions