Menu
Question Index
...

What will be the output of the following program?

class T implements Runnable {
    private static int i = 0;
    public void run() {
        System.out.print(++i + "~");
    }
}
public class TClass {
    public static void main(String args[]) throws Exception {
        Thread thread4 = new Thread(new T());
        Thread thread5 = new Thread(null, thread4, "Thread5", 5);
        thread4.run();
        thread5.run();
    }
}


1~2~
1~2~3~4~5~
1~2~3~4~5~6~
Some other output
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