Menu
Question Index
...

What will be the output of the following program?

public class Void implements Runnable {
    public void run() {
        System.out.println("Running");
        if (Threads2.f) {
            throw new RuntimeException("Problem Occurs");
        }
    }
    public static void main(String[] ary) {
        Threads2.main(ary);
    }
}
class Threads2 implements Runnable {
    static boolean f = false;
    public void run() {
        Threads2.f = true;
    }
    public static void main(String[] args) {
        Thread h = new Thread(new Threads2());
        Thread t = new Thread(new Void());
        t.run();
        System.out.println("Stop");
    }
}


Running
Stop
Running
Problem Occurs
Stop
Running
java.lang.RuntimeException
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