Aggregation and Composition in java

Total Post:149

Points:1043
Java 
 1088  View(s)
Ratings:
Rate this:
can any one explain the aggregation and composition with the low level example that i can understand easily example should be programming example
  1. Post:159

    Points:1117
    Re: Aggregation and Composition in java

    Composition means that the object doesn't make sense without the composed part.

    Aggregation means the aggregated part can exist independently from the object. 

    Example:  a car doesn't make much sense without an axle and vice versa. So a car is composed of an axle. But the CD player in the car can exists independently from the car (in some cases). So the car and the CD player are aggregated.

  1. Post:397

    Points:3117
    Re: Aggregation and Composition in java

    For car example:

    Composition: Car and wheel. 
    Aggregation: Car and passenger.


    This diagram will make the difference more clear among the relationships:

Answer