Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $2.99 payment

Dive into the depths of Java with our quiz based on "Thinking in Java, Fourth Edition" by Bruce Eckel. Test your knowledge, solidify concepts, and prepare for certification with challenging questions and insightful feedback.

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


What method is used for non-blocking file lock acquisition?

  1. lock()

  2. tryLock()

  3. unlock()

  4. release()

The correct answer is: tryLock()

TryLock() is used for non-blocking file lock acquisition. This method tries to acquire a lock on a file and returns a boolean value indicating whether it was successful or not. It does not block the thread and allows it to continue executing if the lock could not be acquired. Lock() is a blocking method and will cause the thread to wait until the lock is acquired. Unlock() and release() are used to release a lock that has already been acquired and do not have anything to do with non-blocking file lock acquisition.