midOOP

What is aggregation vs composition in OOP?

Updated May 17, 2026

Short answer

Aggregation is a weak relationship; composition is a strong ownership relationship.

Deep explanation

In aggregation, objects can exist independently; in composition, child objects depend on parent lifecycle.

Real-world example

A car engine (composition) vs a driver assigned to a car (aggregation).

Common mistakes

  • Confusing ownership strength.

Follow-up questions

  • Which is more tightly coupled?
  • When to use aggregation?

More OOP interview questions

View all →