Menu
Question Index
...

What is the output of the following program?

public class ThreadTest implements Runnable {
    public static void main(String[] args) {
        Thread thread = new Thread(new ThreadTest());
        thread.run(); // LINE A
        try {
            thread.join();
        } catch (Exception e) {
            System.out.println(e);
        }
    }
    public void run() {
        for (int i = 2; i <= 10; i = i + 2) {
            System.out.print(i);
        }
    }
}


2468
246810
Compiles and executes without any output
Compilation Error at LINE A
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