QuizzesDaemon Threads — Concept Check
beginner
operating-systems

Daemon Threads — Concept Check

Questions on Daemon Threads. Daemon threads are background threads that serve other threads and do not prevent the JVM from exiting when all non-daemon threads have finished.

7 minutes 7 questions Pass at 70%
Time Limit
7 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

7 questions on Daemon Threads — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A developer starts a daemon thread for logging and forgets to call setDaemon(true) before starting it. What happens when the main application thread finishes?

    • AThe JVM exits immediately, ignoring the logging thread.
    • BThe logging thread automatically becomes a daemon thread.
    • CThe JVM throws an exception and stops.
    • DThe JVM waits for the logging thread to complete.
  2. 2.In Java, what happens to daemon threads when the last user thread completes?

    • ADaemon threads become user threads automatically.
    • BDaemon threads are terminated immediately.
    • CDaemon threads continue running until they finish their tasks.
    • DDaemon threads pause until the JVM restarts.
  3. 3.A service uses a daemon thread for periodic cache cleanup. What is a risk associated with this setup?

    • AThe daemon thread might become a user thread.
    • BThe cache cleanup may not complete if JVM exits.
    • CThe cache cleanup might block JVM shutdown.
    • DThe daemon thread will prevent other threads from running.
  4. 4.Which of the following tasks is suitable for a daemon thread?

    • AExecuting main application logic.
    • BPerforming periodic log flushing.
    • CSaving user data to a database.
    • DHandling critical transaction processing.
  5. 5.A developer wants to use a daemon thread for a heartbeat monitor. What must they ensure before starting the thread?

    • ACall setDaemon(true) before starting the thread.
    • BSet the thread priority to high.
    • CEnsure the thread is the only one running.
    • DCall setDaemon(true) after starting the thread.
  6. 6.Why should file I/O not be performed in a daemon thread?

    • ADaemon threads cannot perform I/O operations.
    • BDaemon threads are slower at handling I/O tasks.
    • CDaemon threads have lower priority for I/O operations.
    • DDaemon threads might terminate abruptly, leaving I/O incomplete.
  7. 7.A developer mistakenly believes that daemon threads prevent JVM shutdown. What is the correct understanding?

    • ADaemon threads run indefinitely after JVM shutdown.
    • BDaemon threads delay JVM shutdown until they finish.
    • CDaemon threads are ignored during JVM shutdown.
    • DDaemon threads convert to user threads at shutdown.