Inheritance in Java is a mechanism in which one object acquires all the properties and behaviors of a parent object
Inheritance is a technique of modelling real-world relationships, and OOP is all about real-world objects. Here's an example: a car, a bus, and a bicycle all fall under the umbrella term "vehicle." That is, they have inherited the attributes of the vehicle class, implying that they are all utilised for transportation
what is baseclass/super/parent class
what is derived class /subclass/child class
When to use inheritance?
- You can reuse code from the base classes.
Comments
Post a Comment