Bird
Raised Fist0

Which of the following is the correct way to declare a lock object in a typical low-level design for thread safety?

easy๐Ÿง  Conceptual Q12 of Q15
LLD - Advanced LLD Concepts
Which of the following is the correct way to declare a lock object in a typical low-level design for thread safety?
A<code>lock = synchronized()</code>
B<code>lock = new Lock()</code>
C<code>lock = create_lock()</code>
D<code>lock = Lock()</code>
Step-by-Step Solution
Solution:
  1. Step 1: Identify common lock declaration syntax

    In many low-level designs, a lock is created by calling a constructor like Lock().
  2. Step 2: Compare options

    lock = Lock() uses lock = Lock(), which is typical. lock = new Lock() uses 'new' which is not common in low-level design languages. lock = create_lock() and D use incorrect or non-standard functions.
  3. Final Answer:

    lock = Lock() -> Option D
  4. Quick Check:

    Lock creation = Lock() [OK]
Quick Trick: Lock objects are usually created by calling Lock() [OK]
Common Mistakes:
MISTAKES
  • Using 'new' keyword incorrectly
  • Assuming lock creation uses special functions
  • Confusing lock with synchronization keyword

Want More Practice?

15+ quiz questions ยท All difficulty levels ยท Free

Free Signup - Practice All Questions
More LLD Quizzes