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

Discussion

Which of these is the correct signature of Object.wait in its no-argument form?

  • A.public void wait()
  • B.public final boolean wait() throws InterruptedException
  • C.protected final void wait() throws InterruptedException
  • D.public final void wait() throws InterruptedException

Answer: D

wait is public, final and void, and declares InterruptedException. Being final means no class can override it, which is why the behaviour is identical for every object. It returns nothing, so a caller cannot learn from the return value why it woke.

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

Post your comment

Please log in or register to post a comment.