WorksheetsJava thread - MCQ
Total questions: 18
Worksheet time: 9mins
Q) In java multi-threading, a thread can be created by
Extending Thread class
Implementing Runnable interface
Using both
None
Q) Which method is called internally by Thread start() method?
execute()
run()
launch()
main()
Q) What is maximum thread priority in Java
10
12
5
8
Q) Which method must be implemented by a Java thread?
run()
execute()
start()
None
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();
}
}
0
1
2
3
Q) Execution of a java thread begins on which method call?
Start ()
Run ()
Execute ()
Launch ()
Q) How many ways a thread can be created in Java multithreading?
1
2
3
4
Q) Which statements is/are correct (More than one is correct).
On calling Thread start () method a new thread get created.
Thread start () method call run () method internally
Thread run () method can also be called directly to create thread.
All correct
Q) Which method is used to make main thread to wait for all child threads
Join ()
Sleep ()
Wait ()
Stop ()
Q) Default value of a java thread is
0
1
5
10
Q) If a priority of a java thread is 3 then the default priority of its child thread will be
0
1
5
3
Q) Which method is used to check if a thread is running?
isAlive()
run ()
alive ()
keepAlive()
Q) True statement about process and thread is/are
More than one answer
If a child process crashes all main process will also be crashed
If a child thread is crash entire process will crash
Threads have their own memory stack
Each process has different virtual space
Q) Min and Max priority of a thread in Java multithreading are
1, 10
0,10
0,255
1,256
Q) Which method we implement from Runnable interface?
Run ()
Start ()
Execute ()
call ()
Which method is used to wait for child threads to finish in Java?
Wait ()
Sleep ()
Join ()
isAlive()
Q) Which will contain the body of the thread in Java?
Start()
Run()
Main()
Execute()
Q) Thread synchronization in a process will be required when
All threads sharing the same address space
All threads sharing the same global variables
All threads sharing the same files
All
