AGGREGATION AND COMPOSITION IN JAVA

Royce Roy

Total Post:149

Points:1043
Posted by  Royce Roy
Java 
 827  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. Samuel Fernandes

    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. Mayank Tripathi

    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

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!