Bird
Raised Fist0

Which syntax correctly represents the Observer pattern to solve communication?

easy🧠 Conceptual Q3 of Q15
LLD - Behavioral Design Patterns — Part 2
Which syntax correctly represents the Observer pattern to solve communication?
AObserver directly modifies Subject's state
BSubject notifies observers when state changes
CSubject and Observer have no interaction
DObserver polls Subject continuously without notification
Step-by-Step Solution
Solution:
  1. Step 1: Recall Observer pattern basics

    Observer pattern involves Subject notifying Observers on state changes.
  2. Step 2: Identify correct interaction

    Notification is push-based; Observers react to changes without polling or direct modification.
  3. Final Answer:

    Subject notifies observers when state changes -> Option B
  4. Quick Check:

    Observer pattern syntax = B [OK]
Quick Trick: Observer pattern uses notifications, not polling or direct changes [OK]
Common Mistakes:
MISTAKES
  • Thinking observers modify subject directly
  • Assuming no interaction exists
  • Confusing polling with notification

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes