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 happens if a thread calls acquire() on a Semaphore and no permits are available?

  1. The thread terminates

  2. The Semaphore's count is reset

  3. The thread proceeds without waiting

  4. The thread is blocked until a permit is available

The correct answer is: The thread is blocked until a permit is available

When a thread calls acquire() on a Semaphore and there are no permits available, the thread is blocked until a permit becomes available. This means that the thread will pause and wait until a permit is released by another thread.