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

 
 

SCJP Module-8 Question-2
Posted on: July 14, 2010 at 12:00 AM
The program given below will check your concepts of Java Threads and how to used thread in Java.

Given a sample code:

1    public class Test implements Runnable {
2    public void run() {
3    System.out.println("Inside run");
4    }

5    public static void main(String[] args) {
6    // place code here.
7    // place code here.    
8    t.start();
9    System.out.println("End of main");
}}

What statement should be placed at line number 6 and 7 so that result will come as
"Inside run" 
"End of main"

Choose the correct option:

(A) Runnable r = new Runnable(); and Thread t = new Thread(r);
(B) Runnable r = new Thread(); and Thread t = new Thread(r);
(C) Runnable r = new Test(); and Thread t = new Thread(r);
(D) Runnable r = new Test(); and Thread t = new Thread(new Test);

Answer:

(C)

Related Tags for SCJP Module-8 Question-2:


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.