Search This Blog

Friday, January 28, 2011

Question 9

Which of the following statements are true about the sleep method of Thread class? Select two choices.

Options :

A . A thread releases any locks it is holding when it is invoked on the thread.

B. It is defined as static within the Thread class.

C. A Thread starts running as soon as it wakes up from the sleeping state.

D. The sleep method throws InterruptedException.

Answers : B & D

Thread does not release the lock when sleep is invoked on the Thread so Option A is incorrect. A thread cannot be moved to a running state as soon as it wakes up from the sleeping state so Option C is incorrect.

Thread class has a static method with name sleep and it takes argument time in milliseconds. So Option B is Correct. Java API for reference.

image

Sleep method throws InterruptedException when any thread has interrupted the current thread. So option D is correct. Method definition for reference.

image

Question 9SocialTwist Tell-a-Friend

No comments:

Post a Comment