Menu
Topics Index
...
`

Threads2076


If you need explanation Read this topic

If you need Answer Take test on this topic

Threads2076
What will be the output of the following program?
public class IsItCorrect {
    public static void main(String[] args) throws InterruptedException {
        Runnable r = new Runnable() {
            public void run() {
                try {
                    Thread.sleep(1);
                } catch (InterruptedException e) {
                    System.out.print("Interrupted,");
                }
                System.out.print("Run,");
            }
        };
        Thread t = new Thread();
        t.run();
        System.out.print("Started,");
        t.start();
        System.out.print("Interrupting,");
        t.interrupt();
        System.out.print("Ended,");
    }
}

A. Run,Started,Run,Interrupting,Ended,
B. Run,Started,Interrupting,Ended,
C. Started,Interrupting,Ended,
D. Some other output
E. Output can not be determined
F. Compilation Error or 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.

c

Posted by Peta Teja    2014-01-07 09:13:40


ans c, because we are just printing the thread status during its execution

Posted by Kiran Karrolla    2014-01-07 09:40:16


answer is 'F' because we cannot create Object for Runnable because its an interface...

Posted by Sai Teja    2014-01-07 11:34:09


Congratulations Kpyn Kiran. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-01-08 03:50:22


© meritcampus 2019

All Rights Reserved.

Open In App