It denotes that one class is a specialized form of another class.
This relationship is established through inheritance, where the child class inherits the properties and behaviors of the parent class.
“Has-A” Relationship
The “Has-A” relationship represents composition.
It denotes that a class contains one or more objects of another class.
This relationship is established by including objects of one class as fields in another class.
Relationship could be one to one, one to many & many to many.
Association: Relationship b/w two different objects.
Aggregation:
It is a special type of association where one object contains another object.
However, the contained object can exist independently of the container object, i.e., destroying one object will not destroy other object.
It represents a “has-a” relationship but with more independence.
Characteristics of Aggregation:
Weak relationship: The lifecycle of the contained object is not dependent on the container object.
Part-whole relationship: Represents a whole-part relationship where parts can exist independently of the whole.
1. Composition:
1. It is a stronger form of aggregation.
2. In composition, the contained object cannot exist independently of the container object.
3. If the container object is destroyed, the contained object is also destroyed.
4. Characteristics of Composition:
1. Strong relationship: The lifecycle of the contained object is dependent on the container object.
2. Part-whole relationship: Represents a whole-part relationship where parts cannot exist independently of the whole.