KnowledgeBoat Logo

Computer Applications

Provide real-life examples to explain the term, Inheritance.

OOP Intro Java

52 Likes

Answer

To explain Inheritance, let's take the example of traffic on the road. This traffic has some commonalities. It consists of things that can move on the road and transport people and goods from one place to another. We call these things vehicles. 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. We can represent this traffic using Inheritance as shown below. Here, Vehicle is the base class having the common characteristics and behaviours of all Vehicles. Then we have Car, Bike, Bus, Truck as subclasses of Vehicles.

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

Answered By

35 Likes


Related Questions