Sample questions
Question 1Easy
A Department and its Professors: professors continue to exist if the department is closed. This is:
- Inheritance
- Realisation
- Composition
- Aggregation
Answer: D. Aggregation
Explanation
Aggregation is a 'has-a' relationship where parts have an independent lifetime from the whole.
Step-by-step solution
- Professors exist even if the department is closed.
- This shows professors are separate from the department.
- Aggregation means parts can live without the whole.
- So, this is Aggregation.
- Final answer: D (Aggregation).
Why the other options are wrong
- A. Inheritance is an is-a link between classes, not a whole-part link between objects.
- B. Realisation is a class implementing an interface, not a department owning professors.
- C. Composition means the parts die with the whole, which professors do not.
Tip: Remember: Aggregation = independent parts, Composition = dependent parts.
Question 2Easy
Composition and aggregation are both specialised forms of:
- Association
- Inheritance
- Realisation
- Dependency injection
Answer: A. Association
Explanation
- Both describe a structural link between objects (whole-part);
- they differ in ownership strength and lifetime.
Step-by-step solution
- Composition and aggregation are types of object relationships.
- They both represent whole-part connections.
- Association is the general term for such relationships.
- Composition and aggregation are specialised forms of association.
- Final answer: A (Association).
Why the other options are wrong
- B. Inheritance is a separate relationship, not a parent of composition and aggregation.
- C. Realisation means implementing an interface, which is not a parent of these two.
- D. Dependency injection is a design pattern for supplying dependencies, not a relationship type.
Tip: Remember: association is the general term for whole-part relationships.
Question 3Easy
A House and its Rooms: rooms cannot exist without the house and are destroyed with it. This relationship is:
- Composition
- Dependency
- Association only
- Aggregation
Answer: A. Composition
Explanation
Composition is a strong 'part-of' relationship in which the part's lifetime is bound to the whole.
Step-by-step solution
- Rooms are parts of a house and cannot exist without it.
- The life of rooms ends when the house is destroyed.
- This shows a strong 'part-of' relationship.
- Composition means part's lifetime is tied to the whole.
- Final answer: Composition.
Why the other options are wrong
- B. Dependency is a weaker, temporary use of another class, not a whole-part lifetime link.
- C. Association only says two classes are linked; it does not tie rooms' lifetime to the house.
- D. Aggregation is a whole-part link where parts can live on, so the rooms would survive.
Tip: Remember composition for parts that cannot exist without the whole.
Question 4Easy
A Teacher teaches many Students and a Student has many Teachers. This association's multiplicity is:
- One-to-many
- Many-to-many
- Zero-to-one
- One-to-one
Answer: B. Many-to-many
Explanation
Both ends allow multiple instances (* on each end), so it is a many-to-many association.
Step-by-step solution
- One Teacher teaches many Students.
- One Student has many Teachers.
- Both ends are many, so the multiplicity is many-to-many; index 1 is correct.
Why the other options are wrong
- A. One-to-many would need each Student to have only one Teacher.
- C. Zero-to-one describes an optional single link.
- D. One-to-one allows only one link on each side.
Tip: Count the links from each end: many on both sides means many-to-many.
Question 5Medium
'A Car has an Engine' and 'A SportsCar is a Car'. Which pair of relationships do these describe?
- Inheritance, then composition
- Both are aggregation
- Both are inheritance
- Composition (has-a), then inheritance (is-a)
Answer: D. Composition (has-a), then inheritance (is-a)
Explanation
'has-a' suggests containment (an engine is part of the car); 'is-a' suggests a subtype relationship.
Step-by-step solution
- A Car has an Engine shows composition (has-a).
- A SportsCar is a Car shows inheritance (is-a).
- Composition means one object contains another.
- Inheritance means one class is a subtype of another.
- So the relationships are composition then inheritance.
Why the other options are wrong
- A. A Car having an Engine is composition, not inheritance, so the first pair is wrong.
- B. Car has an Engine is not aggregation here, and is-a is never aggregation.
- C. Only the SportsCar-is-a-Car part is inheritance; the Car-has-an-Engine part is not.
Tip: Remember: 'has-a' is composition, 'is-a' is inheritance.
Question 6Medium
In a UML class diagram, a solid line with a hollow triangular arrowhead pointing to a class represents:
- Dependency
- Generalisation (inheritance)
- Aggregation
- Navigable association
Answer: B. Generalisation (inheritance)
Explanation
The hollow triangle points from the subclass to the superclass; a dashed line with the same head means realisation of an interface.
Step-by-step solution
- A solid line signals a structural (not temporary) relationship between the two classes.
- A hollow (unfilled) triangular arrowhead specifically marks 'is-a' / inheritance.
- The arrow points from the subclass to the superclass it extends.
Why the other options are wrong
- A. Dependency uses a dashed line with a plain open arrowhead, not a solid line with a hollow triangle.
- C. Aggregation uses a solid line with a hollow DIAMOND at the whole-side end, not a triangle.
- D. A plain navigable association uses a simple open arrowhead on a solid line, without the hollow triangle.
Tip: Hollow triangle = 'is-a' family (inheritance or interface realisation); the line style then tells you which of the two.
Question 7Medium
In UML, the multiplicity '0..*' on an association end means:
- Zero or more instances
- At least one
- Zero or one
- Exactly zero
Answer: A. Zero or more instances
Explanation
0..* (or just ) allows any number including none; 1.. requires at least one; 0..1 means optional single.
Step-by-step solution
- Multiplicity states how many instances can sit at an association end.
- 0..* means the lower bound is 0 and the upper bound is unlimited.
- So it means zero or more instances; the correct answer is option A.
Why the other options are wrong
- B. At least one would be written 1..*.
- C. Zero or one would be written 0..1.
- D. Exactly zero would be written 0..0.
Tip: Means many; the first number is the minimum.
Question 8Medium
In UML, an italicised class name (or the stereotype <<abstract>>) indicates that the class is:
- An interface implementation
- Final
- Static
- Abstract
Answer: D. Abstract
Explanation
Abstract classes and abstract operations are shown in italics in UML class diagrams.
Step-by-step solution
- In UML, an italic class name marks the class as abstract.
- The abstract stereotype marks the same thing.
- So index 3, Abstract, is correct.
Why the other options are wrong
- A. Interface implementation is not shown by italics.
- B. Final is not shown by italics in UML.
- C. Static is shown by underlining the member, not the class name.
Tip: Italic class name or the abstract stereotype means abstract; an underlined member means static.
Question 9Hard
Which UML diagram best shows the time-ordered messages exchanged between objects for one scenario?
- Package diagram
- Deployment diagram
- Sequence diagram
- Class diagram
Answer: C. Sequence diagram
Explanation
Sequence diagrams show lifelines and messages along a vertical time axis; class diagrams show static structure.
Step-by-step solution
- The question asks for time-ordered messages in one scenario.
- A sequence diagram shows objects as lifelines with messages drawn top to bottom in time order.
- So the correct answer is option C, the sequence diagram.
Why the other options are wrong
- A. A package diagram shows groups of classes.
- B. A deployment diagram shows hardware and software nodes.
- D. A class diagram shows structure, not message order.
Tip: Sequence = time going down the page.
Question 10Hard
Which UML relationship is shown by a dashed line with a hollow triangle pointing to an interface?
- Usage dependency
- Realisation (the class implements the interface)
- Composition
- Generalisation between two classes
Answer: B. Realisation (the class implements the interface)
Explanation
Realisation means a classifier implements the contract of another, typically a class implementing an interface.
Step-by-step solution
- A dashed line means 'not a permanent structural link', the same convention as plain dependency.
- A hollow triangle on that dashed line means 'conforms to the same contract' - the same idea as inheritance.
- Together, dashed line + hollow triangle means: this class implements that interface's contract.
Why the other options are wrong
- A. A plain usage dependency is drawn with a simple open arrowhead, without the hollow triangle.
- C. Composition is drawn with a solid line and a filled diamond, not a dashed line with a triangle.
- D. Generalisation between two classes uses a SOLID line (since a class actually inherits implementation), not dashed.
Tip: Solid triangle-arrow = extends a class; dashed triangle-arrow = implements an interface.
Practise all 17 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →