exam questions

Exam 1z0-829 All Questions

View all questions & answers for the 1z0-829 exam

Exam 1z0-829 topic 1 question 29 discussion

Actual exam question from Oracle's 1z0-829
Question #: 29
Topic #: 1
[All 1z0-829 Questions]

Which statement is true?

  • A. The lock() method returns a boolean indicator immediately regardless if it has or has not managed to acquire the lock.
  • B. The lock() method returns a boolean indicator immediately if it has managed to acquire the lock, otherwise it waits for the lock acquisition.
  • C. The tryLock() method returns a boolean indicator immediately if it has managed to acquire the lock, otherwise it waits for the lock acquisition.
  • D. The tryLock() method returns a boolean indicator immediately regardless if it has or has not managed to acquire the lock.
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
SrinivasJasti
2 weeks, 2 days ago
Selected Answer: D
tryLock() Attempts to acquire the lock in a non-blocking manner. Returns: true if the lock was acquired successfully. false if the lock could not be acquired immediately. It does not wait for the lock to become available.
upvoted 1 times
...
supersquax
5 months, 2 weeks ago
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.
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago