Menu
Topics Index
...
`

About Thread2347


If you need explanation Read this topic

If you need Answer Take test on this topic

About Thread2347
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());
    }
}

A. Main - 5
Main - main
Run - I am Thread
Run - 8
B. Main - 8
Main - I am Thread
Run - I am Thread
Run - 8
C. Main - 5
Main - main
Run - main
Run - 5
D. Some other output
E. Output can not be determined
F. Compilation Error or Runtime Error
Topic: What is Multitasking and Multithreading?

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

Ans is E.
we cannot determine output.

Posted by Gopinath Manchikanti    2014-08-08 08:50:39


Ans is E..we cant determine bcz switchng bwt thraed wil don by procesor

Posted by Uday Kumar    2014-08-08 08:52:25


ans is a mains priority is 5 n defined threads priority is 8  

Posted by PaWan Mulchandani    2014-08-08 08:52:35


ans is E output cannot be determined

Posted by Ramya Reddy Addulla    2014-08-08 10:16:39


Congratulations Uday Kumar. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-08-11 04:31:34


© meritcampus 2019

All Rights Reserved.

Open In App