wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Thread Priorities

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What decides thread priority?

a)

Process

b)

Process scheduler

c)

Thread

d)

Thread scheduler

2.

Which of the following line of code is suitable to start a thread ?

class MyThread implements Runnable

{

public static void main(String args[])

{

/* Missing code? */

}

public void run() {}

}

a)

Thread t = new Thread(X);

b)

Thread t = new Thread(X); t.start();

c)

MyThread run = new MyThread();

Thread t = new Thread(run);

t.start();

d)

Thread t = new Thread(); x.run();

3.

What will be the output of the program?

class multithreaded_programing

{

public static void main(String args[])

{

Thread t = Thread.currentThread();

t.setName("New Thread");

System.out.println(t);

}

}

a)

Thread[5,main].

b)

Thread[New Thread,5].

c)

Thread[main,5,main].

d)

Thread[New Thread,5,main]

4.

What is the name of the thread in output of this program?

class multithreaded_programing

{

public static void main(String args[])

{

Thread t = Thread.currentThread();

System.out.println(t.getPriority());

}

}

a)

0

b)

1

c)

5

d)

10

5.

What is the name of the thread in output of this program?

class multithreaded_programing

{

public static void main(String args[])

{

Thread t = Thread.currentThread();

System.out.println(t.isAlive());

}

}

a)

0

b)

1

c)

TRUE

d)

FALSE

6.

What requires less resources?

a)

Thread

b)

Process

c)

Thread and Process

d)

Neither Thread nor Process

7.

What does not prevent JVM from terminating?

a)

Process

b)

Daemon Thread

c)

User Thread

d)

JVM Thread

8.

Which method is called internally by Thread start() method?

a)

execute()

b)

run()

c)

launch()

d)

main()

9.

Execution of a java thread begins on which method call?

a)

start ()

b)

run ()

c)

execute ()

d)

launch ()

10.

Which method is used to make main thread to wait for all child threads?

a)

join ()

b)

sleep ()

c)

wait ()

d)

stop ()