Bird
Raised Fist0

Consider this pseudocode for deleting a book record:

medium📝 Analysis Q13 of Q15
LLD - Design — Library Management System
Consider this pseudocode for deleting a book record:
if book_id exists:
    delete book
    return 'Deleted'
else:
    return 'Not Found'
What will be the output if book_id does not exist?
A'Deleted'
B'Not Found'
CError: book_id missing
DNo output
Step-by-Step Solution
Solution:
  1. Step 1: Analyze condition for book_id existence

    The code checks if book_id exists; if not, it goes to else branch.
  2. Step 2: Determine output when book_id missing

    Else branch returns 'Not Found' when book_id does not exist.
  3. Final Answer:

    'Not Found' -> Option B
  4. Quick Check:

    Missing book_id returns 'Not Found' [OK]
Quick Trick: If condition false, else output runs [OK]
Common Mistakes:
MISTAKES
  • Assuming deletion happens without book_id
  • Expecting an error instead of 'Not Found'
  • Ignoring else branch output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes