Bird
0
0

Which method signature correctly belongs to a Command interface supporting undo?

easy🧠 Conceptual Q12 of 15
LLD - Design — Tic-Tac-Toe Game
Which method signature correctly belongs to a Command interface supporting undo?
Avoid save(); void load();
Bvoid execute(); void undo();
Cvoid start(); void finish();
Dvoid run(); void stop();
Step-by-Step Solution
Solution:
  1. Step 1: Identify standard Command interface methods

    The Command pattern typically defines an execute() method to perform the action and an undo() method to reverse it.
  2. Step 2: Match method signatures

    Only void execute(); void undo(); has execute() and undo(), matching the Command pattern for undo.
  3. Final Answer:

    void execute(); void undo(); -> Option B
  4. Quick Check:

    Command methods = execute and undo [OK]
Quick Trick: Look for execute() and undo() methods [OK]
Common Mistakes:
MISTAKES
  • Choosing unrelated method names like run/stop
  • Confusing start/finish with undo functionality
  • Assuming save/load are Command methods

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes