ProgrammingModerateProduct-company placement · Java

A Department has Professors who continue to exist if the department is closed, while a House is made of Rooms that cannot exist without the house. These two relationships are, respectively:

  1. A. Composition and aggregation
  2. B. Inheritance and composition
  3. C. Aggregation and composition
  4. D. Association and inheritance

Correct answer: C. Aggregation and composition

Both are has-a relationships; in composition the part's lifetime is owned by the whole (rooms die with the house), while in aggregation the parts are shared and independent.

More OOP with C++ and Java questions

Exams that ask this topic