0
0
LLDsystem_design~20 mins

Object-oriented design principles in LLD - Practice Problems & Coding Challenges

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

Which of the following best describes the Single Responsibility Principle in object-oriented design?

AA class should have only one reason to change, meaning it should have only one job or responsibility.
BA class should inherit from multiple classes to reuse code efficiently.
CA class should expose all its data members publicly for easy access.
DA class should handle multiple unrelated functionalities to reduce the number of classes.
Attempts:
2 left
💡 Hint

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

Architecture
intermediate
2:00remaining
Applying Open/Closed Principle (OCP)

You have a payment processing system that needs to support new payment methods without modifying existing code. Which design approach aligns best with the Open/Closed Principle?

AModify the existing payment class each time a new payment method is added.
BUse global variables to switch between payment methods inside the existing class.
CCreate a new class for each payment method that inherits from a common payment interface.
DCombine all payment methods into a single class with many conditional statements.
Attempts:
2 left
💡 Hint

Consider how to add new features without changing existing code.

scaling
advanced
2:00remaining
Scaling with Liskov Substitution Principle (LSP)

In a large system, you have a base class Vehicle and subclasses like Car and ElectricCar. Which design choice violates the Liskov Substitution Principle?

A<code>ElectricCar</code> overrides a method from <code>Vehicle</code> but throws an exception when called.
B<code>ElectricCar</code> inherits from <code>Car</code> and uses all inherited methods correctly.
C<code>Car</code> extends <code>Vehicle</code> and adds new methods specific to cars.
DAll subclasses can be used wherever <code>Vehicle</code> is expected without altering program correctness.
Attempts:
2 left
💡 Hint

Think about substituting subclasses without breaking the program.

tradeoff
advanced
2:00remaining
Tradeoffs in Interface Segregation Principle (ISP)

Which scenario best illustrates a violation of the Interface Segregation Principle?

AMultiple small interfaces are created for specific client needs.
BA client class depends on an interface with many methods it does not use.
CA class implements only the methods it requires from an interface.
DInterfaces are designed to be minimal and focused on single responsibilities.
Attempts:
2 left
💡 Hint

Consider how clients should depend on interfaces.

estimation
expert
3:00remaining
Estimating Impact of Violating Dependency Inversion Principle (DIP)

In a layered system, high-level modules directly depend on low-level modules instead of abstractions. What is the most likely impact of this design choice?

AHigh-level modules can be reused independently without any changes.
BThe system becomes more flexible and easier to maintain due to direct dependencies.
CLow-level modules automatically adapt to changes in high-level modules.
DThe system becomes tightly coupled, making it hard to change or extend low-level modules without affecting high-level modules.
Attempts:
2 left
💡 Hint

Think about coupling and flexibility between layers.