Menu
Question Index
...

What will be the output of the following program?

public class AboutThread extends Thread {
    private AboutThread() {
        setName("I am Thread");
        setPriority(8);
    }
    public void run() {
        System.out.println("Run - " + Thread.currentThread().getName());
        System.out.println("Run - " + Thread.currentThread().getPriority());
    }
    public static void main(String[] args) {
        new AboutThread().start();
        System.out.println("Main - " + Thread.currentThread().getPriority());
        System.out.println("Main - " + Thread.currentThread().getName());
    }
}


Main - 5
Main - main
Run - I am Thread
Run - 8
Main - 8
Main - I am Thread
Run - I am Thread
Run - 8
Main - 5
Main - main
Run - main
Run - 5
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