What is the difference between association and composition?
Keeping this in consideration, what is Association aggregation and composition explain with examples?
Aggregation implies a relationship where the child can exist independently of the parent. Example: Class (parent) and Student (child). Delete the Class and the Students still exist. Composition implies a relationship where the child cannot exist independent of the parent. Example: House (parent) and Room (child).
Consequently, what is composition in object oriented programming?
Composition is one of the fundamental concepts in object-oriented programming. It describes a class that references one or more objects of other classes in instance variables. This allows you to model a has-a association between objects. You can find such relationships quite regularly in the real world.
Key Differences Between Aggregation and Composition As against, in composition, the child entity is dependent on the parent. In aggregation there exist a “has a” relationship whereas in composition there is a “part of” relationship between the assembly and constituent class objects.