Элементы композиции HAS A
Наследование означает IS A
Example
: автомобиль имеет двигатель и автомобиль - это автомобиль
. При программировании это выглядит как:
class Engine {} // The Engine class.
class Automobile {} // Automobile class which is parent to Car class.
class Car extends Automobile { // Car is an Automobile, so Car class extends Automobile class.
private Engine engine; // Car has an Engine so, Car class has an instance of Engine class as its member.
}