CS FundamentalsModerateInfosys · Wipro

An editor must save snapshots of a document's internal state so it can be restored later, without exposing the document's private fields to the caretaker that stores the snapshots. Which pattern does this?

  1. A. Command
  2. B. Memento
  3. C. Prototype
  4. D. Observer

Correct answer: B. Memento

Memento lets the originator export its state into an opaque object that only the originator can read back; the caretaker just stores mementos. This preserves encapsulation, unlike making the fields public.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic