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

Discussion

Which of these Thread methods is static?

  • A.join
  • B.interrupt
  • C.setName
  • D.sleep

Answer: D

Correct answer: sleep

sleep is static because it acts on whichever thread is executing the call, not on the object it is written against. Writing t.sleep(100) compiles but puts the calling thread to sleep, which is misleading enough that compilers warn about it. join, interrupt and setName all act on a particular thread and are instance methods.

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

Post your comment

Please log in or register to post a comment.