Exam 1z0-829 All QuestionsBrowse all questions from this exam
Question 29

Which statement is true?

    Correct Answer: D

    The correct statement is that the tryLock() method returns a boolean indicator immediately regardless of whether it has managed to acquire the lock. The tryLock() method is designed to attempt to acquire the lock immediately, returning true if successful and false otherwise, without waiting. This behavior is distinct from the lock() method, which does not return a value immediately.

Discussion
supersquaxOption: D

D is correct, you can read more about it here: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/Lock.html#tryLock-- the lock() method doesnt return anything, so A and B are wrong. tryLock() always returns a boolean immediately, no waiting involved. returns True immediately if and only if the thread is available and successfully locked, otherwise false.