Topics Index

Output of Thread2358

If you need explanation Read this topic

If you need Answer Take test on this topic

Output of Thread2358
What will be the output of the following program?
public class OutputOfThread extends Thread {
    private OutputOfThread() {
    public void run() {
        System.out.print("Run = ");
        System.out.println(Thread.currentThread().getPriority() + Thread.currentThread().getPriority());
    public static void main(String[] args) {
        OutputOfThread oft = new OutputOfThread();
        System.out.print("Main = ");
        System.out.println(Thread.MAX_PRIORITY + Thread.MIN_PRIORITY + Thread.NORM_PRIORITY);

A. Main = 16
Run = 2
B. Main = 1015
Run = 11
C. Some other output
D. Output can not be determined
E. 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 A
because min_priority=10,max= 1 and norm=5..(10+1+5=16)
and thread's priority is set to norm priority that is 1 (1+1=2)
so main=16

Posted by Mânïshå Mùlchåndânï    2014-07-15 12:50:48

Answer a.
max+min+norm priorities =10+1+5=16
getpriority givs 1

Posted by NagaRaj Nataraj    2014-07-15 12:54:56

Answer a.
max priority-10
min priority-1
norm priority-5
in main methd sop prints-
main= 10+1+5=16.
outputof thread contructor givs recently cald setpriority value wen getpriority() cald.
so min priority value 1 is priority value of currnt thtead
run() methd prints

Posted by Maheshwari Natarajan    2014-07-15 13:11:57

output cannot be determined........

Posted by Arul Palanisamy    2014-07-15 14:52:02

Congratulations Mânïshå Mùlchåndânï. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-07-16 05:35:43

© meritcampus 2019

All Rights Reserved.

Open In App