Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java thread - MCQ

Total questions: 18

Worksheet time: 9mins

Name
Class
Date
1.

Q) In java multi-threading, a thread can be created by

a)

Extending Thread class

b)

Implementing Runnable interface

c)

Using both

d)

None

2.

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

a)

execute()

b)

run()

c)

launch()

d)

main()

3.

Q) What is maximum thread priority in Java

a)

10

b)

12

c)

5

d)

8

4.

Q) Which method must be implemented by a Java thread?

a)

run()

b)

execute()

c)

start()

d)

None

5.

Q) Number of threads in below java program is

public class ThreadExtended extends Thread {


public void run() {

System.out.println("\nThread is running now\n");

}


public static void main(String[] args) {


ThreadExtended threadE = new ThreadExtended();


threadE.start();

}

}

a)

0

b)

1

c)

2

d)

3

6.

Q) Execution of a java thread begins on which method call?

a)

Start ()

b)

Run ()

c)

Execute ()

d)

Launch ()

7.

Q) How many ways a thread can be created in Java multithreading?

a)

1

b)

2

c)

3

d)

4

8.

Q) Which statements is/are correct (More than one is correct).

a)

On calling Thread start () method a new thread get created.

b)

Thread start () method call run () method internally

c)

Thread run () method can also be called directly to create thread.

d)

All correct

9.

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

a)

Join ()

b)

Sleep ()

c)

Wait ()

d)

Stop ()

10.

Q) Default value of a java thread is

a)

0

b)

1

c)

5

d)

10

11.

Q) If a priority of a java thread is 3 then the default priority of its child thread will be

a)

0

b)

1

c)

5

d)

3

12.

Q) Which method is used to check if a thread is running?

a)

isAlive()

b)

run ()

c)

alive ()

d)

keepAlive()

13.

Q) True statement about process and thread is/are

More than one answer

a)

If a child process crashes all main process will also be crashed

b)

If a child thread is crash entire process will crash

c)

Threads have their own memory stack

d)

Each process has different virtual space

14.

Q) Min and Max priority of a thread in Java multithreading are

a)

1, 10

b)

0,10

c)

0,255

d)

1,256

15.

Q) Which method we implement from Runnable interface?

a)

Run ()

b)

Start ()

c)

Execute ()

d)

call ()

16.

Which method is used to wait for child threads to finish in Java?

a)

Wait ()

b)

Sleep ()

c)

Join ()

d)

isAlive()

17.

Q) Which will contain the body of the thread in Java?

a)

Start()

b)

Run()

c)

Main()

d)

Execute()

18.

Q) Thread synchronization in a process will be required when

a)

All threads sharing the same address space

b)

All threads sharing the same global variables

c)

All threads sharing the same files

d)

All