TJR Bootcamp Practice Test

Access More Questions
Which design pattern lets observers subscribe to changes in another object?
Correct Answer:
Observer pattern
Explanation:
The key idea here is that one object can notify others about its changes through a subscription mechanism. In this pattern, a subject keeps a list of observers that have expressed interest, and whenever the subject’s state changes, it sends out a notification to all registered observers. Observers can subscribe or unsubscribe at runtime, and their responses are triggered by those notifications. This decouples the subject from the observers, so the subject doesn’t need to know who’s watching or what they’ll do with the update. That dynamic, broadcast-style relationship is what makes this pattern the right fit for letting observers subscribe to changes in another object. A practical example is a model in a UI: when the model changes, it notifies all registered views, and each view updates accordingly. The other patterns aren’t about notifying dependents: a Singleton ensures a single instance, a Factory focuses on creating objects, and an Adapter translates interfaces between SAMPLEcomponents.

Access more questions from this quiz

Continue to TJR Bootcamp Practice Test for more practice questions and the full quiz experience.

Access More Questions