Back to Topic 7.2 — OOP: multiple classes
7.2.4Computer Science HL5 flashcards

Composition and aggregation

Practice Flashcards

Flip to reveal answers
Card 1 of 57.2.4
7.2.4
Question

Composition or aggregation — what is the difference?

Click to reveal answer

Track your progress — Sign up free to save your progress and get smart review reminders based on spaced repetition.

All 5 Flashcards — Composition and aggregation

Sign up free to track progress and get spaced-repetition review schedules.

Card 1comparison

Question

Composition or aggregation — what is the difference?

Answer

Both are has-a. **Composition** owns the part, which dies with the whole. **Aggregation** references a part that exists independently.

Card 2process

Question

What is the survival test?

Answer

Delete the whole. If the part still makes sense it is **aggregation**; if it is meaningless it is **composition**.

Card 3example

Question

What is the tell in code?

Answer

The whole **creating** the part inside itself → composition. The part **passed in** → aggregation.

Card 4definition

Question

Which UML diamond means composition?

Answer

The **filled** diamond ◆. A hollow diamond ◇ means aggregation.

Card 5concept

Question

Why prefer composition over inheritance?

Answer

Looser coupling (interface, not internals), parts swappable at run time, and none of the parent's unwanted members.

Track your progress with spaced repetition

Sign up free — Aimnova tells you exactly which cards to review and when, so you remember everything before your IB exam.

Start Free
IB Computer Science Composition and aggregation Flashcards | 7.2.4 | Aimnova