UML MCQ

UML Diagrams MCQs Questions With Answers – Part 20

Test your knowledge and boost your confidence with these multiple-choice quizzes focused on UML diagrams, foundational software engineering concepts, and real-world best practices. Designed for students, developers, and exam candidates, these MCQs offer a quick and effective way to assess your understanding and sharpen your skills.
 
 

1. If a “Flying Interface” defines the behavior of “flying”, and an “Airplane” implements this capability, what UML relationship is at play?

A Generalization (the airplane is a type of flying)

B Dependency (the airplane needs the concept of flying)

C Realization (the airplane realizes the ability to fly)

D Association (airplanes and flying exist together)

C
The realization shows that a class (Airplane) implements the operations specified by an interface (Flying). Example:
 
 

2. What is the role of stereotypes (<< >>) in UML?

A Add comments to a UML diagram.

B Modify the behavior of a class at runtime.

C Extend the UML vocabulary to add domain-specific meanings.

D Define the primitive data types used in UML.

C
Stereotypes are a way to extend UML to include elements suited to particular domains or contexts. For example, <<interface>>, <<entity>>, <<control>>, etc. They help enrich the semantics of models.
 

3. What is the role of an alt combined fragment in a sequence diagram?

A Represent parallel interactions.

B Represent an iteration of a message.

C Represent a set of alternative conditions (like if…else).

D Represent a recursive message call.

C
The alt (alternative) fragment allows modeling scenarios where different execution branches may occur depending on conditions. Very useful for representing choices in a use case or interaction. Example:
 
 
 

4. In a UML activity diagram, what is the difference between a fork and a join?

A The fork splits a flow, the join ends it.

B The fork synchronizes flows, the join splits them.

C The fork splits a flow into multiple parallel flows, the join synchronizes them.

D There is no difference, they are two names for the same symbol.

C
A fork sends control to multiple activities in parallel, while a join waits for all parallel activities to finish before continuing. They are represented by a horizontal or vertical black line. Example:
 
 

5. Imagine a “Conductor” who uses a “Baton” to direct music. How does UML capture this temporary usage?

A Composition (they are a single musical entity)

B Aggregation (they often work together)

C Association (they exist in the same musical world)

D Dependency (the act of conducting uses the wand)

D
The baton is necessary for the act of conducting, but the conductor exists independently of this specific baton. Example:
 
 

6. To visualize the “drawers” and “shirts” inside a “Dresser”, showing that the drawers are contained within the dresser, which UML structural diagram is relevant?

A Object diagram (a specific dresser with its contents)

B Class diagram (types of dressers and drawers)

C Component diagram (software parts of a smart dresser)

D Deployment diagram (where the dresser is placed in the house)

B
The class diagram allows modeling the composition relationship (the dresser intrinsically contains the drawers) between types of entities. Example:
 
 
 

7. Which UML design pattern is most often modeled with an association between a class and itself?

A Observer

B Singleton

C Composite

D Factory

C
The Composite pattern relies on a hierarchical structure where a “Component” class contains references to other objects of the same type, creating a self-association (a class associated with itself). Very common for modeling trees.
 

8. Which statement is true regarding an abstract class in a UML class diagram?

A It can be instantiated directly.

B It cannot have operations.

C It must inherit from another class.

D It usually contains abstract operations (not implemented).

D
An abstract class serves as a base for other classes and cannot be instantiated directly. It often contains abstract methods that derived classes must implement.
 

9. What is the consequence of this relationship between Cart and Inventory?


A Cart and Inventory are subclasses that inherit from Stockable

B Stockable is a superclass of Cart and Inventory

C Cart and Inventory independently implement the Stockable interface

D Both classes must be combined into one class

C
In UML, interfaces are implemented, and here Cart and Inventory both have an implementation relationship with Stockable, meaning they share the same behaviors defined in the interface.
 
 

10. You are modeling a messaging app. Which UML relationship represents that a user can send multiple messages?

A Dependency

B Composition

C Inheritance

D Association with multiplicity

D
Each user is linked to multiple messages, so a 1..* association is ideal. Example:
 
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *