Bird
0
0

Given the enum SpotType { COMPACT, LARGE, HANDICAPPED } and a function that assigns spots based on vehicle type, what will be the output if a VehicleType.TRUCK is assigned a SpotType.COMPACT?

medium📝 Analysis Q4 of 15
LLD - Design — Parking Lot System
Given the enum SpotType { COMPACT, LARGE, HANDICAPPED } and a function that assigns spots based on vehicle type, what will be the output if a VehicleType.TRUCK is assigned a SpotType.COMPACT?
AAssignment successful: Truck parked in COMPACT spot.
BAssignment successful: Truck parked in LARGE spot.
CError: SpotType COMPACT does not exist.
DError: Truck cannot be assigned to COMPACT spot.
Step-by-Step Solution
Solution:
  1. Step 1: Understand vehicle to spot compatibility

    Trucks require LARGE spots; COMPACT spots are too small.
  2. Step 2: Analyze assignment result

    Assigning a TRUCK to a COMPACT spot should cause an error or rejection.
  3. Final Answer:

    Error: Truck cannot be assigned to COMPACT spot. -> Option D
  4. Quick Check:

    Truck to COMPACT spot = error [OK]
Quick Trick: Match vehicle size to spot size to avoid errors [OK]
Common Mistakes:
MISTAKES
  • Assuming all vehicles fit any spot
  • Ignoring spot size constraints
  • Confusing spot existence with compatibility

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes