The sample program given below will test your knowledge about the sleep() method in Java.
The sample program given below will test your knowledge about the sleep() method in Java.Given a sample code:
public class Test {
public static void main(String[] args) throws Exception {
System.out.println("inside main");
Thread.sleep(2000);
System.out.println("thread sleep");
}
}
Which of the following statement is correct ?
(A) Print "inside main" and "thread sleep"
(B) Compilation fails.
(C) An exception is thrown at runtime.
(D) Print "thread sleep" and "inside main"
(A)