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

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

Prepare for your Java exam with our ultimate quiz based on 'Thinking in Java'. Engage with expertly crafted questions that enhance your learning process. Perfect for Java enthusiasts looking to solidify their knowledge!

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.