nerdexam
Oracle

1Z0-829 · Question #2

Which statement is true?

The correct answer is C. A thread in waiting state must handle InterruptedException. Option C is correct because methods that place a thread in a waiting state - such as Object.wait(), Thread.sleep(), and Thread.join() - all declare throws InterruptedException. Since this is a checked exception, the Java compiler mandates that calling code either catches it or…

Managing concurrent code execution

Question

Which statement is true?

Options

  • AIllegalStateException is thrown if a thread in waiting state is moved back to runnable.
  • BThread in waiting state consumes CPU cycles.
  • CA thread in waiting state must handle InterruptedException.
  • DAfter the timed wait expires, the waited thread moves to the terminated state.

How the community answered

(50 responses)
  • A
    6% (3)
  • B
    2% (1)
  • C
    78% (39)
  • D
    14% (7)

Explanation

Option C is correct because methods that place a thread in a waiting state - such as Object.wait(), Thread.sleep(), and Thread.join() - all declare throws InterruptedException. Since this is a checked exception, the Java compiler mandates that calling code either catches it or propagates it, making handling it a syntactic requirement, not just a best practice.

Why the distractors are wrong:

  • A - No IllegalStateException is thrown during a waiting-to-runnable transition. That exception is thrown for invalid state in other contexts (e.g., calling start() on an already-started thread).
  • B - A waiting thread is deliberately not consuming CPU cycles; the entire purpose of wait() is to release the CPU (and the monitor lock) until notified.
  • D - When a timed wait expires, the thread returns to the runnable state, not terminated. Terminated means run() has finished.

Memory tip: InterruptedException is a checked exception - the compiler won't let you ignore it. Anytime you see wait(), sleep(), or join(), think "I must handle InterruptedException" because Java enforces it at compile time.

Topics

#thread states#InterruptedException#concurrent execution#exception handling

Community Discussion

No community discussion yet for this question.

Full 1Z0-829 Practice