Bird
0
0

Identify the problem in this Mediator implementation:

medium📝 Analysis Q6 of 15
LLD - Behavioral Design Patterns — Part 2
Identify the problem in this Mediator implementation:
class Mediator {
  notify(sender, event) {
    console.log('Event received: ' + event);
  }
}
const mediator = new Mediator();
mediator.notify('ComponentX');
Anotify method should not log events
Bnotify method is missing the event argument when called
CMediator class should not have notify method
DNo problem, code works fine
Step-by-Step Solution
Solution:
  1. Step 1: Check method signature

    notify expects two parameters: sender and event.
  2. Step 2: Check method call

    notify is called with only one argument ('ComponentX'), missing event parameter.
  3. Final Answer:

    notify method is missing the event argument when called -> Option B
  4. Quick Check:

    Method call arguments must match signature [OK]
Quick Trick: Method calls must match parameter count [OK]
Common Mistakes:
MISTAKES
  • Ignoring missing parameters
  • Assuming default values for missing args
  • Misunderstanding method purpose

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes