MCQ- Java multithreading multiple choice questions with answers and explanation. 50% of the MCQ on multithreading in java are asked in interviews. But, additional objective questions have been added to cover java thread concept.
Q) In java multi-threading, a thread can be created by
- Extending Thread class
- Implementing Runnable interface
- Using both
- None
Answer: 3
In java multi-threaded program, a thread can be created using both by extending Thread class and Implementing Runnable interface. Read thread java example using both thread class and runnable interface .
Q) Which method is called internally by Thread start() method?
- execute()
- run()
- launch()
- main()
Answer: 2
Thread start() method internally calls run() method. All statements inside the run method is get executed by the thread.
Q) What is maximum thread priority in Java
- 10
- 12
- 5
- 8
Answer: 1
Q) Which method must be implemented by a Java thread?
- run()
- execute()
- start()
- None
Answer: 1
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
Answer: 3 : 2 threads are there.
Main program is also run as a thread. And, program has created one child thread. Hence, total 2 threads are there in the program.