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

 
 

Share on Google+Share on Google+
SCJP Module-8 Question-2
Posted on: July 14, 2010 at 12:00 AM
Advertisement
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)

Advertisement

Related Tags for SCJP Module-8 Question-2:


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.

Posted on: July 14, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com