SCJP Module-8 Question-8


 

SCJP Module-8 Question-8

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"

Answer:

(A)

Ads