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

Discussion

Which of these is the correct signature of Object.wait with a timeout in milliseconds and nanoseconds?

  • A.public final void wait(long timeout, long nanos) throws InterruptedException
  • B.public final boolean wait(long timeout, int nanos)
  • C.public void wait(int timeout, int nanos) throws InterruptedException
  • D.public final void wait(long timeout, int nanos) throws InterruptedException

Answer: D

The milliseconds argument is a long and the nanoseconds a small int, and the method is final and void. Returning a boolean would have let a caller distinguish a timeout from a notification, which this API deliberately does not offer.

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

Post your comment

Please log in or register to post a comment.