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

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

Mastering Java: The Ultimate Quiz for 'Thinking in Java'. Dive deep into Java with multiple-choice questions. Challenge yourself with quiz questions designed to test and improve your understanding of the 'Thinking in Java' book. Get ready for your exam!

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.