Bird
0
0

Which of the following is the correct method name to notify observers in a typical observer pattern implementation?

easy📝 Conceptual Q12 of 15
LLD - Design — Online Shopping Cart
Which of the following is the correct method name to notify observers in a typical observer pattern implementation?
Aunsubscribe()
BupdateState()
Csubscribe()
DnotifyObservers()
Step-by-Step Solution
Solution:
  1. Step 1: Recall observer pattern methods

    Common methods include subscribe, unsubscribe, and notifyObservers.
  2. Step 2: Identify the method that sends updates

    notifyObservers() is used to alert all subscribed observers about changes.
  3. Final Answer:

    notifyObservers() -> Option D
  4. Quick Check:

    Notify method = notifyObservers() [OK]
Quick Trick: Notify method usually named notifyObservers() [OK]
Common Mistakes:
  • Confusing subscribe with notify
  • Using updateState() which changes state, not notify
  • Mixing unsubscribe with notification

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes