Bird
Raised Fist0

Which of the following is the correct way to define a Mediator interface in a low-level design?

easy🧠 Conceptual Q12 of Q15
LLD - Behavioral Design Patterns — Part 2
Which of the following is the correct way to define a Mediator interface in a low-level design?
Ainterface Mediator { void notify(Component sender, String event); }
Bclass Mediator { void notifyAll(); }
Cinterface Mediator { void sendMessage(String message); }
Dclass Mediator { void receive(Component sender); }
Step-by-Step Solution
Solution:
  1. Step 1: Identify typical Mediator method signature

    The Mediator usually has a method to notify it about events from components, often with sender and event details.
  2. Step 2: Match method signatures to this pattern

    interface Mediator { void notify(Component sender, String event); } matches this pattern with notify(Component sender, String event). Others lack sender info or use incorrect method names.
  3. Final Answer:

    interface Mediator { void notify(Component sender, String event); } -> Option A
  4. Quick Check:

    Notify method with sender and event = B [OK]
Quick Trick: Mediator notify method includes sender and event [OK]
Common Mistakes:
MISTAKES
  • Omitting sender parameter in notify method
  • Using generic sendMessage without context
  • Naming methods incorrectly for Mediator role

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes