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

Disable ads (and more) with a membership for a one time $4.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.

Practice this question and more.


What happens if 'shutdown()' is called on an ExecutorService?

  1. The ExecutorService immediately stops all running tasks

  2. The ExecutorService stops accepting new tasks

  3. All threads are converted to daemon threads

  4. The computer shuts down

The correct answer is: The ExecutorService stops accepting new tasks

When 'shutdown()' is called on an ExecutorService, the ExecutorService stops accepting new tasks but it does not immediately stop all running tasks. Instead, it allows currently running tasks to finish before shutting down. Option C is incorrect because it refers to all threads being converted to daemon threads, which is not the case when 'shutdown()' is called. Option A is incorrect because it states that the ExecutorService immediately stops all running tasks, which is not true. Option D is incorrect because it states that the computer shuts down, which is not related to the behavior of calling 'shutdown()' on an ExecutorService.