Home Tutorial Java Scjp Part8 SCJP Module-8 Question-7

 
 

SCJP Module-8 Question-7
Posted on: July 15, 2010 at 12:00 AM
The Sample program given below will check your knowledge about the Runnable interface Thread class in Java.

Given a sample code:

public class Test implements Runnable {
public void run() {
System.out.print("run");
}

public static void main(String[] args) {
Runnable r = new Test();
Thread t = new Thread(r);
t.run();
t.start();
t.run();
}
}

Which of the following statement is correct ?

(A) Compilation fails.
(B) Print "run run run"
(C) An exception is thrown at runtime.
(D) Print "run"

Answer:

(B)

Related Tags for SCJP Module-8 Question-7:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.