Menu
Topics Index
...
`

Threads1689


If you need explanation Read this topic

If you need Answer Take test on this topic

Threads1689
What is the output of the following program?
public class ThreadTest implements Runnable {
    public static void main(String[] args) {
        Thread thread = new Thread(new ThreadTest());
        thread.run(); // LINE A
        try {
            thread.join();
        } catch (Exception e) {
            System.out.println(e);
        }
    }
    public void run() {
        for (int i = 2; i <= 10; i = i + 2) {
            System.out.print(i);
        }
    }
}

A. 2468 
B. 246810
C. Compiles and executes without any output
D. Compilation Error at LINE A
E. Runtime Error
Topic: What is Multitasking and Multithreading?

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

ans should b B as the there r no errors.. n thread.run calls run method n executes it..

Posted by Pramod Jain    2013-08-16 03:39:51


A

Posted by Prasanth Hero    2013-08-16 03:48:59


ans :b method execute sucessfully

Posted by Sravan Haram    2013-08-16 11:27:06


Congratulations Pramod Jain. You are this dose winner. Please send us your mobile details and we will process the recharge asap.

Posted by Merit Campus    2013-08-17 05:00:15


© meritcampus 2019

All Rights Reserved.

Open In App