Bird
Raised Fist0
LLDsystem_design~20 mins

UML class diagrams basics in LLD - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
UML Class Diagram Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Identify the correct UML class diagram element

Which UML class diagram element represents a blueprint for objects, including attributes and methods?

AClass
BObject
CPackage
DInterface
Attempts:
2 left
💡 Hint

Think about what defines the structure and behavior of objects in UML.

❓ Architecture
intermediate
2:00remaining
Determine the correct relationship type in UML class diagrams

In a UML class diagram, which relationship type shows that one class owns or contains another class as a part?

ADependency
BAggregation
CInheritance
DAssociation
Attempts:
2 left
💡 Hint

Consider the difference between whole-part relationships and simple links.

❓ scaling
advanced
2:00remaining
Estimate the number of classes needed for a library management system UML diagram

You are designing a UML class diagram for a library system with books, members, loans, and staff. Which is the most reasonable number of classes to represent these entities and their relationships?

A4 classes: Book, Member, Loan, Staff
B20 classes including all possible details and external systems
C2 classes: Book and Member
D10 classes including Book, Member, Loan, Staff, Catalog, Reservation, Fine, Librarian, Publisher, Author
Attempts:
2 left
💡 Hint

Think about capturing main entities and their interactions without overcomplicating.

❓ tradeoff
advanced
2:00remaining
Choose the best UML relationship for representing a strict inheritance hierarchy

Which UML relationship should you use to show that one class is a specialized version of another, inheriting its attributes and methods?

AAssociation
BAggregation
CInheritance (Generalization)
DDependency
Attempts:
2 left
💡 Hint

Think about the 'is-a' relationship in object-oriented design.

❓ component
expert
3:00remaining
Trace the request flow in a UML class diagram for a user login process

Given a UML class diagram with classes: UserInterface, AuthController, UserService, and Database, which sequence correctly represents the flow of a login request?

A1,2,3,4,5,6
B1,3,2,4,5,6
C2,1,3,4,5,6
D1,2,4,3,5,6
Attempts:
2 left
💡 Hint

Follow the logical order of method calls from UI to database and back.

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

  1. Step 1: Understand UML class diagram purpose

    A UML class diagram shows how classes are organized and connected in a system.
  2. 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.
  3. Final Answer:

    The structure of classes and their relationships -> Option A
  4. 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

  1. Step 1: Recall UML attribute notation

    Attributes use visibility (+ public, - private, # protected), name, colon, and type.
  2. Step 2: Match options to notation

    + attributeName : Type matches correct format: '+ attributeName : Type'. Others use wrong symbols or separators.
  3. Final Answer:

    + attributeName : Type -> Option D
  4. 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

  1. Step 1: Interpret visibility symbols

    '+' means public, '-' means private in UML.
  2. Step 2: Apply to attributes

    'name' has '+', so public; 'age' has '-', so private.
  3. Final Answer:

    'name' is public and 'age' is private -> Option B
  4. 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

  1. Step 1: Check UML attribute syntax

    Attributes use visibility, name, colon ':', then type. '=' is not used.
  2. Step 2: Identify incorrect symbol

    The '=' sign is wrong; it should be ':' to separate attribute name and type.
  3. Final Answer:

    The '=' sign should be ':' to separate name and type -> Option C
  4. 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

  1. 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.
  2. 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.
  3. Final Answer:

    Aggregation from Author to Book (one-to-many) -> Option A
  4. 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 unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard