Bird
Raised Fist0

In the LoanManager class, a developer writes code that updates the loan status without synchronizing access in a multi-threaded environment. What is the most likely bug caused by this omission?

medium🐞 Bug Identification Q7 of Q15
OOP & Design Patterns - Design a Library Management System - LLD with Relationships & Edge Cases
In the LoanManager class, a developer writes code that updates the loan status without synchronizing access in a multi-threaded environment. What is the most likely bug caused by this omission?
ADeadlock due to improper locking order
BMemory leak from unreleased resources
CStack overflow due to recursive loan updates
DRace condition causing inconsistent loan status updates
Step-by-Step Solution
Solution:
  1. Step 1: Identify missing synchronization in multi-threaded access

    Without synchronization, concurrent threads can access and modify shared data simultaneously.
  2. Step 2: Understand race conditions

    This leads to race conditions where loan status updates may be lost or corrupted.
  3. Step 3: Exclude other bugs

    Deadlock requires locking; memory leak unrelated to synchronization; stack overflow requires recursion.
  4. Final Answer:

    Option D -> Option D
  5. Quick Check:

    Unsynchronized access -> race condition [OK]
Quick Trick: No synchronization -> race condition on shared data [OK]
Common Mistakes:
MISTAKES
  • Confusing race condition with deadlock
  • Assuming memory leak from sync issues
  • Thinking recursion causes this bug
Trap Explanation:
PITFALL
  • Candidates often confuse concurrency bugs, picking deadlock or memory leak instead of race condition.
Interviewer Note:
CONTEXT
  • Checks concurrency bug identification and understanding of synchronization importance.
Master "Design a Library Management System - LLD with Relationships & Edge Cases" in OOP & Design Patterns

2 interactive learning modes - each teaches the same concept differently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More OOP & Design Patterns Quizzes