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.


Which method reduces the count in CountDownLatch?

  1. reduce()

  2. decrement()

  3. countDown()

  4. awaitDecrease()

The correct answer is: countDown()

The method that reduces the count in CountDownLatch is called countDown(). This method decrements the count of the latch, which indicates that a task has completed. Option A, reduce(), and option B, decrement(), are not applicable to CountDownLatch. Option A is used to combine values in a stream, while option B is used to decrement the count in a separate type of synchronization object called a semaphore. Option D, awaitDecrease(), is not a valid method in the CountDownLatch class. Therefore, the correct answer is option C, countDown().