Which of the following statements correctly distinguishes Composition from…

2023

Which of the following statements correctly distinguishes Composition from Aggregation in Object-Oriented Programming (OOP)?

  1. A.

    Aggregation represents stronger dependency than Composition

  2. B.

    In Composition, the child object depends on the lifecycle of the parent object

  3. C.

    Composition allows child objects to exist independently of the parent

  4. D.

    Aggregation and Composition both represent identical relationships

  5. E.

    Composition is used only for multiple inheritance relationships

Attempted by 2 students.

Show answer & explanation

Correct answer: B

Concept

Composition and Aggregation are both forms of association (a "has-a" relationship) between objects, but they differ in the strength of ownership and, crucially, in lifecycle dependency. Composition is a strong whole-part relationship in which the part cannot exist without the whole: when the containing (parent) object is destroyed, its contained (child) objects are destroyed with it. Aggregation is a weaker relationship in which the part has an independent lifecycle and can continue to exist on its own after the whole is gone.

Applying it here

The question asks for the statement that correctly tells the two apart. The single defining contrast is lifecycle dependency: in Composition the child's existence is bound to the parent's lifecycle, so the statement "In Composition, the child object depends on the lifecycle of the parent object" captures exactly the property that separates it from Aggregation.

Contrast with the alternatives

  • "Aggregation is a stronger dependency than Composition" reverses the strength order — Composition is the stronger, tightly-coupled relationship, not Aggregation.

  • "Composition lets the child exist independently of the parent" describes Aggregation, not Composition; independent existence of the part is the hallmark of the weaker relationship.

  • "Both represent identical relationships" erases the distinction the question is built on — they are deliberately different in ownership and lifecycle.

  • "Composition is used only for multiple inheritance" confuses object association with class inheritance; Composition is about objects containing other objects, and is in fact often favoured as an alternative to inheritance.

Memory aid

Composition = "dies with the owner" (a House and its Rooms); Aggregation = "survives the owner" (a Team and its Players, who exist before and after the team).

Explore the full course: Ibps So It Mains

Loading lesson…