Menu
Question Index
...

What will be the output of the following program?

public class IsItCorrect {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread();
        Runnable r = new Runnable() {
            public void run() {
                try {
                    t.sleep(1);
                } catch (InterruptedException e) {
                    System.out.print("Interrupted,");
                }
                System.out.print("Run,");
            }
        };
        t.run();
        System.out.print("Started,");
        t.start();
        System.out.print("Ended,");
    }
}


Started,Interrupted,Run,Ended,
Started,Run,Ended,
Started,Ended,
Some other output
Output can not be determined
Compilation Error or Runtime Error

Doubts

Problems

Topic: What is Multitasking and Multithreading?

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App