Exam-style question
Try this first
A class diagram contains a single inheritance relationship, one composition relationship and one aggregation relationship. Explain how these three relationships differ, state the UML notation for the two whole-part relationships, and describe how polymorphism can be used in an object-oriented program involving inheritance.
Answer and explanation
Concise answer
Inheritance is a relationship in which one class derives from another class and can use or extend characteristics and behaviours from the other class.
Why this is correct
The answer must distinguish inheritance from the two whole-part relationships, identify black diamond for composition and white diamond for aggregation, and connect polymorphism with related classes and class-specific behaviour. Mentioning overriding is relevant because it is an object-oriented concept in the specification and can support polymorphic behaviour.
Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.
Common mistake
No common mistake is linked to this question yet.
