Java SE 17 Developer — Question 27
Which statement is true?
Answer options
- A. IllegalStateException is thrown if a thread in waiting state is moved back to runnable.
- B. A thread in waiting state consumes CPU cycles.
- C. After the timed wait expires, the waited thread moves to the terminated state.
- D. A thread in waiting state must handle InterruptedException.
Correct answer: D
Explanation
The correct answer is D because a thread in a waiting state can be interrupted and must handle the InterruptedException to manage this scenario properly. Option A is incorrect since moving a thread from waiting to runnable does not throw IllegalStateException. Option B is false as a thread in waiting does not consume CPU cycles, and Option C is incorrect because a thread returns to the runnable state after a timed wait, not terminated.