0
0
LLDsystem_design~20 mins

Interface Segregation Principle in LLD - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
ISP Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding Interface Segregation Principle (ISP)

Which statement best describes the Interface Segregation Principle?

AInterfaces should be merged to reduce the number of classes in a system.
BAll classes should implement a single large interface to ensure consistency.
CInterfaces should only be used for database access layers.
DClients should not be forced to depend on interfaces they do not use.
Attempts:
2 left
💡 Hint

Think about how interfaces affect client dependencies and code flexibility.

Architecture
intermediate
2:00remaining
Applying ISP in a Payment System

You are designing a payment system with multiple payment methods: CreditCard, PayPal, and Bitcoin. Which design best follows the Interface Segregation Principle?

ACreate a single interface IPayment with a generic pay() method that all payment classes implement.
BDo not use interfaces; implement payment methods directly in one class.
CCreate separate interfaces for each payment method: ICreditCardPayment, IPayPalPayment, IBitcoinPayment. Each payment class implements only the relevant interface.
DCreate one large interface IPayment with methods: payWithCreditCard(), payWithPayPal(), payWithBitcoin(). All payment classes implement all methods.
Attempts:
2 left
💡 Hint

Consider how to avoid forcing classes to implement methods they don't need.

scaling
advanced
2:30remaining
Scaling a Notification System with ISP

A notification system supports Email, SMS, and Push notifications. As the system grows, which approach best supports scalability and follows ISP?

AUse one interface INotification with methods sendEmail(), sendSMS(), sendPush(). All notification classes implement all methods.
BCreate separate interfaces IEmailNotification, ISMSNotification, IPushNotification. Notification classes implement only the interfaces they support.
CImplement all notification methods in a single NotificationManager class without interfaces.
DUse a single interface with a send(type, message) method handling all notification types.
Attempts:
2 left
💡 Hint

Think about how adding new notification types affects existing classes.

tradeoff
advanced
1:30remaining
Tradeoffs of Interface Segregation Principle

What is a common tradeoff when applying the Interface Segregation Principle in system design?

AIt can increase the number of interfaces, making the system more complex to manage.
BIt forces all clients to depend on a single large interface, reducing flexibility.
CIt eliminates the need for interfaces, simplifying the codebase.
DIt requires all classes to implement every method, increasing code duplication.
Attempts:
2 left
💡 Hint

Consider the balance between interface size and system complexity.

component
expert
2:00remaining
Identifying ISP Violation in Code Components

Given a system with a Printer interface having methods print(), scan(), fax(), and a class BasicPrinter implementing all methods but only supporting print(), what problem does this design illustrate?

AViolation of Interface Segregation Principle because BasicPrinter depends on methods it does not use.
BCorrect use of ISP because all methods are in one interface.
CViolation of Single Responsibility Principle because BasicPrinter does too many things.
DNo problem; this is standard interface design.
Attempts:
2 left
💡 Hint

Think about whether classes should implement methods they don't support.