Java SE 8 Programmer II — Question 139
Which two statements are true about synchronization and locks? (Choose two.)
Answer options
- A. A thread automatically acquires the intrinsic lock on a synchronized statement when executed.
- B. The intrinsic lock will be retained by a thread if return from a synchronized method is caused by an uncaught exception.
- C. A thread exclusively owns the intrinsic lock of an object between the time it acquires the lock and the time it releases it.
- D. A thread automatically acquires the intrinsic lock on a synchronized method's object when entering that method.
- E. Threads cannot acquire intrinsic locks on classes.
Correct answer: A, B
Explanation
Option A is correct because a thread does indeed automatically acquire the intrinsic lock when executing a synchronized statement. Option B is also correct, as the lock remains with the thread even if it exits due to an uncaught exception. Options C, D, and E are incorrect as they misrepresent the behavior of lock acquisition and ownership in Java's synchronization model.