Share on Google+Share on Google+

SCJP Module-8 Question-8

Advertisement
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)

Advertisements

Posted on: July 15, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.