, , . , , :
Vehicle
|
__________
| |
Car Bike
, Car Bike Vehicle, , Vehicle Car Bike. Java . , Car , Vehicle. Bike. , Car Bike, . Cars Vehicles, Vehicles Cars. Bikes. Car Bike .
You do this to create more extensible code. For example, you can write code that understands how to interact with code that will be written in the future. An example of this is some common interface, for example drive(), which allows other developers to later provide custom implementations. Your code, although written before it, can still work with it, because it can handle new subclasses as if they were instances of a base class.
source
share