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

Discussion

Which of these methods declares InterruptedException?

  • A.Thread.isAlive
  • B.Thread.sleep
  • C.Thread.yield
  • D.Thread.interrupt

Answer: B

sleep is declared to throw InterruptedException, so a caller must handle or declare it. yield, interrupt and isAlive declare no checked exception and can be called without a try block. join also declares it, for the same reason as sleep.

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

Post your comment

Please log in or register to post a comment.