Machine-translated by Google. Questions are authored in English.
Top

Discussion

What is the return type of Thread.interrupted()?

  • A.Thread
  • B.boolean
  • C.void
  • D.int

Answer: B

Correct answer: boolean

Thread.interrupted() reports whether the current thread has been interrupted and clears the flag as it does so, which is the trap in the name. isInterrupted() is the instance method that reports without clearing, and confusing the two loses interrupts.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.