A UML class diagram is a visual representation that shows the structure of a system by displaying its classes, their attributes, methods, and the relationships between them.
Click to reveal answer
beginner
What are the three main parts of a UML class diagram box?
The three main parts are: 1) Class name at the top, 2) Attributes (properties) in the middle, 3) Methods (operations) at the bottom.
Click to reveal answer
beginner
What does an association relationship represent in a UML class diagram?
An association shows a connection between two classes, meaning objects of one class use or are linked to objects of another class.
Click to reveal answer
intermediate
What is the difference between inheritance and composition in UML class diagrams?
Inheritance means one class is a specialized version of another (is-a relationship). Composition means one class contains another class as a part (has-a relationship) and controls its lifecycle.
Click to reveal answer
intermediate
How is multiplicity shown in UML class diagrams and what does it mean?
Multiplicity is shown near the ends of association lines as numbers or ranges (e.g., 1, 0..*, *). It indicates how many instances of a class can be linked to instances of another class.
Click to reveal answer
Which part of a UML class diagram shows the class's functions?
AThe top compartment
BThe bottom compartment
CThe middle compartment
DOutside the box
✗ Incorrect
The bottom compartment lists the methods or operations of the class.
What does a solid line with a hollow triangle arrow represent in UML?
AInheritance
BAssociation
CComposition
DDependency
✗ Incorrect
A solid line with a hollow triangle arrow shows inheritance (generalization).
If a class 'Car' has a composition relationship with 'Engine', what does it mean?
ACar uses Engine temporarily
BCar is a type of Engine
CCar contains Engine and controls its lifecycle
DCar and Engine are unrelated
✗ Incorrect
Composition means Car has an Engine as a part and controls its lifecycle.
What does multiplicity '0..*' mean in a UML association?
AExactly zero instances
BOne instance only
CAt least one instance
DZero or many instances
✗ Incorrect
'0..*' means zero or many instances can be linked.
Which UML diagram focuses on showing classes and their relationships?
AClass diagram
BUse case diagram
CSequence diagram
DActivity diagram
✗ Incorrect
Class diagrams show classes and their relationships.
Describe the main components of a UML class diagram and their purpose.
Think about the box parts and how classes connect.
You got /4 concepts.
Explain the difference between inheritance and composition with simple examples.
Use real-life objects like animals or cars.
You got /3 concepts.
Practice
(1/5)
1. What does a UML class diagram primarily represent in system design?
easy
A. The structure of classes and their relationships
B. The sequence of operations in a process
C. The deployment of hardware components
D. The flow of data between systems
Solution
Step 1: Understand UML class diagram purpose
A UML class diagram shows how classes are organized and connected in a system.
Step 2: Compare options to definition
Only The structure of classes and their relationships describes structure of classes and relationships, which matches UML class diagrams.
Final Answer:
The structure of classes and their relationships -> Option A
Quick Check:
UML class diagram = class structure [OK]
Hint: Class diagrams show classes and links, not processes or hardware [OK]
Common Mistakes:
Confusing class diagrams with sequence diagrams
Thinking class diagrams show hardware layout
Mixing data flow diagrams with class diagrams
2. Which of the following is the correct way to show a class attribute in a UML class diagram?
easy
A. * attributeName -> Type
B. - attributeName = Type
C. # attributeName - Type
D. + attributeName : Type
Solution
Step 1: Recall UML attribute notation
Attributes use visibility (+ public, - private, # protected), name, colon, and type.
Step 2: Match options to notation
+ attributeName : Type matches correct format: '+ attributeName : Type'. Others use wrong symbols or separators.
Final Answer:
+ attributeName : Type -> Option D
Quick Check:
Attribute syntax = + name : Type [OK]
Hint: Attributes use visibility + name : Type format [OK]
Common Mistakes:
Using '=' instead of ':' to separate name and type
Confusing visibility symbols
Using arrows or dashes incorrectly
3. Given this UML class snippet: + name : String - age : int Which statement is true about the attributes?
medium
A. 'name' is private and 'age' is public
B. 'name' is public and 'age' is private
C. Both 'name' and 'age' are public
D. Both 'name' and 'age' are private
Solution
Step 1: Interpret visibility symbols
'+' means public, '-' means private in UML.
Step 2: Apply to attributes
'name' has '+', so public; 'age' has '-', so private.
Final Answer:
'name' is public and 'age' is private -> Option B
Quick Check:
+ = public, - = private [OK]
Hint: Plus means public, minus means private [OK]
Common Mistakes:
Mixing up '+' and '-' meanings
Assuming all attributes are public by default
Ignoring visibility symbols
4. Identify the error in this UML class attribute declaration: - salary = float
medium
A. Visibility symbol '-' is incorrect
B. Type 'float' should be capitalized
C. The '=' sign should be ':' to separate name and type
D. Attribute name 'salary' is invalid
Solution
Step 1: Check UML attribute syntax
Attributes use visibility, name, colon ':', then type. '=' is not used.
Step 2: Identify incorrect symbol
The '=' sign is wrong; it should be ':' to separate attribute name and type.
Final Answer:
The '=' sign should be ':' to separate name and type -> Option C
Quick Check:
Use ':' not '=' in attributes [OK]
Hint: Use ':' not '=' between name and type [OK]
Common Mistakes:
Using '=' instead of ':'
Thinking visibility symbols are wrong
Assuming type names must be capitalized
5. You want to model a simple library system with classes Book and Author. Each book has one author, and an author can write many books. Which UML relationship best represents this?
hard
A. Aggregation from Author to Book (one-to-many)
B. Composition from Book to Author (one-to-one)
C. Inheritance from Book to Author
D. Association from Book to Author (many-to-many)
Solution
Step 1: Understand relationship types
Aggregation means a whole-part with shared lifecycle; composition means strong ownership; inheritance means 'is-a' relation; association is a general link.
Step 2: Apply to library example
Author writes many books (one-to-many). Books can exist without author object lifecycle tightly bound, so aggregation fits best.
Final Answer:
Aggregation from Author to Book (one-to-many) -> Option A
Quick Check:
One author, many books = aggregation [OK]
Hint: One-to-many ownership without strong lifecycle = aggregation [OK]
Common Mistakes:
Confusing composition with aggregation
Using inheritance for unrelated classes
Choosing many-to-many when one-to-many fits
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.