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 will happen to the daemon threads when the JVM exits?

  1. They continue running

  2. They are paused

  3. They are stopped

  4. They are serialized

The correct answer is: They are stopped

Daemon threads are background threads that continue to run even after the main thread ends. When the JVM exits, all threads, including daemon threads, are terminated. This is because daemon threads are meant to be supporting threads for the main thread and do not have any critical job or purpose. Therefore, they are not set to run indefinitely like normal threads. Pausing and serializing the daemon threads would prevent the JVM from exiting, as these actions would keep the threads in a running state. Thus, option A and D are incorrect. Option B is also incorrect as pausing a thread does not terminate it. Overall, when the JVM exits, all threads including daemon threads are stopped or terminated.