In object-oriented design, which statement best describes composition?

Get ready for your Object‑Oriented Programming Test. Use flashcards and multiple-choice questions. Each question includes hints and explanations. Prepare for your exam today!

Multiple Choice

In object-oriented design, which statement best describes composition?

Explanation:
Composition captures the idea of strong ownership: a whole controls the creation and lifecycle of its parts. The statement that a part belongs to the whole and is destroyed with it expresses that lifecycle tie—when the whole is created, the parts are created as part of it, and when the whole is destroyed, the parts are released as well. This makes the parts non-sharable and not expected to survive independently of the container. It contrasts with the idea of parts existing independently or with an is-a relationship, which describe different concepts entirely: independent parts point to aggregation or ordinary associations, while is-a refers to inheritance rather than containment. So the described property—exclusive ownership and tied lifecycles—best captures composition.

Composition captures the idea of strong ownership: a whole controls the creation and lifecycle of its parts. The statement that a part belongs to the whole and is destroyed with it expresses that lifecycle tie—when the whole is created, the parts are created as part of it, and when the whole is destroyed, the parts are released as well. This makes the parts non-sharable and not expected to survive independently of the container. It contrasts with the idea of parts existing independently or with an is-a relationship, which describe different concepts entirely: independent parts point to aggregation or ordinary associations, while is-a refers to inheritance rather than containment. So the described property—exclusive ownership and tied lifecycles—best captures composition.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy