Bird
0
0

Consider this pseudo-code for confirming a hold:

medium📝 Analysis Q13 of 15
LLD - Design — Library Management System
Consider this pseudo-code for confirming a hold:
if hold.exists(hold_id) and not hold.is_expired(hold_id):
    reservation.create(hold.resource)
    hold.remove(hold_id)
    return "Confirmed"
else:
    return "Failed"
What will be the output if the hold has expired?
A"Failed"
B"Confirmed"
CError due to missing hold
D"Confirmed" but resource is double booked
Step-by-Step Solution
Solution:
  1. Step 1: Check hold existence and expiration

    The code confirms only if hold exists and is not expired.
  2. Step 2: Analyze expired hold case

    If hold is expired, condition fails and returns "Failed" without creating reservation.
  3. Final Answer:

    "Failed" -> Option A
  4. Quick Check:

    Expired hold = "Failed" confirmation [OK]
Quick Trick: Expired holds cause confirmation to fail [OK]
Common Mistakes:
MISTAKES
  • Assuming expired holds confirm successfully
  • Expecting errors instead of failure message
  • Ignoring hold expiration check

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes