Bird
0
0

What is the likely error?

medium📝 Analysis Q6 of 15
LLD - Design — Elevator System
In a state machine for an elevator, the code snippet below causes the elevator to never open its doors. What is the likely error? if (state == 'MovingUp' || state == 'MovingDown') { state = 'Idle'; } // Missing door open transition
AState should never be Idle
BDoorOpen state transition is missing after Idle
CMovingUp and MovingDown states are incorrect
DEvent handling is not needed
Step-by-Step Solution
Solution:
  1. Step 1: Analyze code behavior

    The code moves from Moving states directly to Idle without opening doors.
  2. Step 2: Identify missing transition

    Elevator should transition to DoorOpen state after Idle to simulate door opening.
  3. Final Answer:

    DoorOpen state transition is missing after Idle -> Option B
  4. Quick Check:

    Missing DoorOpen transition [OK]
Quick Trick: DoorOpen state must follow movement stop [OK]
Common Mistakes:
MISTAKES
  • Skipping door open state
  • Misunderstanding Idle state role
  • Ignoring event-driven transitions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes