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?
- A. Command
- B. Memento
- C. Prototype
- 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.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- In an air-traffic system, 20 aircraft objects would each need references to all the others to coordinate landings. Routing every message…
- How many of these differences between Proxy and Decorator are correct? 1. Both implement the same interface as the object they wrap. 2. A…
- A class Invoice has methods calculateTotal(), saveToDatabase() and renderPdf(). Which principle does it violate, and what is the usual fix?
- A Worker interface declares work(), eat() and sleep(). RobotWorker implements it and leaves eat() and sleep() throwing 'not supported'…
- How many of these subclass changes violate the Liskov Substitution Principle? 1. The overriding method accepts a wider range of inputs…
- An area calculator contains if shape.type == "circle": … elif shape.type == "square": …, and every new shape requires editing this…