0
0
LLDsystem_design~20 mins

Class responsibilities and behavior in LLD - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Class Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Single Responsibility Principle

Which of the following best describes the Single Responsibility Principle (SRP) in class design?

AA class should have only one reason to change, meaning it should have only one responsibility.
BA class should handle multiple responsibilities to reduce the number of classes in the system.
CA class should inherit from multiple classes to gain various behaviors.
DA class should expose all its internal data to other classes for flexibility.
Attempts:
2 left
💡 Hint

Think about how many reasons a class should have to change.

Architecture
intermediate
2:00remaining
Class Behavior Distribution in a Library Management System

In a library management system, which class should be responsible for checking out a book to a user?

AThe Book class, because it represents the book being checked out.
BThe Library class, because it manages the collection of books.
CA separate CheckoutManager class, responsible for managing the checkout process.
DThe User class, because it represents the person borrowing the book.
Attempts:
2 left
💡 Hint

Consider which class should handle the process involving multiple entities.

scaling
advanced
2:30remaining
Scaling Class Responsibilities in a Messaging App

As a messaging app grows, which approach best helps to keep class responsibilities manageable and scalable?

AAvoid creating new classes and use global functions for all behaviors.
BCombine all message handling, user management, and notification logic into a single MessageService class.
CLet each class handle unrelated tasks to reduce the number of classes in the system.
DDivide responsibilities into specialized classes like MessageHandler, UserManager, and NotificationService.
Attempts:
2 left
💡 Hint

Think about how to keep classes focused and easy to maintain as the system grows.

tradeoff
advanced
2:30remaining
Tradeoffs in Class Responsibility Granularity

What is a potential downside of making classes too fine-grained with very narrow responsibilities?

AIt can lead to too many classes, making the system complex to navigate and maintain.
BIt always improves performance by reducing class size.
CIt reduces code reuse by forcing duplication in each class.
DIt eliminates the need for interfaces or abstractions.
Attempts:
2 left
💡 Hint

Consider what happens when there are many small classes in a system.

component
expert
3:00remaining
Identifying Class Responsibilities in a Ride-Sharing System

In a ride-sharing system, which class should be responsible for calculating the fare of a ride?

AThe Driver class, because the driver provides the service.
BThe FareCalculator class, dedicated to computing fares based on ride details and pricing rules.
CThe Ride class, because it represents the trip details and duration.
DThe User class, because the user pays the fare.
Attempts:
2 left
💡 Hint

Think about separating calculation logic from data representation.