Bird
Raised Fist0

In an emergency system, this code snippet causes a problem:

medium📝 Analysis Q14 of Q15
LLD - Design — Elevator System
In an emergency system, this code snippet causes a problem:
if sensor.detect():
alert.send()
safety.activate()
log.record()

What is the main issue?
AMissing indentation causes log.record() to run always
Bsafety.activate() is outside the if block
Calert.send() is not called properly
Dlog.record() runs even if no detection
Step-by-Step Solution
Solution:
  1. Step 1: Check code indentation

    log.record() is not indented under the if, so it runs always.
  2. Step 2: Understand impact

    log.record() runs even when sensor.detect() is false, which is incorrect behavior.
  3. Final Answer:

    Missing indentation causes log.record() to run always -> Option A
  4. Quick Check:

    Indentation controls conditional execution [OK]
Quick Trick: Indent all emergency actions inside detection check [OK]
Common Mistakes:
MISTAKES
  • Ignoring indentation importance
  • Assuming all lines are inside if by default
  • Confusing which lines run conditionally

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes