Menu
Question Index
...

What will be the output of the following program?

public class Opticals {
    public static void main(String[] args) {
        System.out.print("Output");
        new Opticals().doSomething();
    }
    public void doSomething() {
        final int i = 5;
        Thread t = new Thread(new Runnable() {
            public void run() {
                for (int j = 0; j <= i; j++) {
                    System.out.print("~" + j);
                }
            }
        });
        t.start();
    }
}


(EMPTY)
Output~0~1~2~3~4
Output~0~1~2~3~4~5
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