Bird
0
0

In the Observer pattern, what is the key responsibility of an Observer object?

easy🧠 Conceptual Q1 of 15
LLD - Behavioral Design Patterns — Part 1

In the Observer pattern, what is the key responsibility of an Observer object?

AMaintain the list of all observers
BReceive updates from the Subject when its state changes
CChange the state of the Subject
DNotify other observers about changes
Step-by-Step Solution
Solution:
  1. Step 1: Understand Observer role

    The Observer's main role is to get notified about changes in the Subject.
  2. Step 2: Analyze options

    Only Receive updates from the Subject when its state changes correctly describes the Observer's responsibility to receive updates.
  3. Final Answer:

    Receive updates from the Subject when its state changes -> Option B
  4. Quick Check:

    Observer listens for changes [OK]
Quick Trick: Observer receives updates from Subject [OK]
Common Mistakes:
MISTAKES
  • Confusing Observer with Subject responsibilities
  • Thinking Observer modifies Subject state

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes