MCQ- Java thread

(Last Updated On: March 26, 2018)

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
  1. Extending Thread class
  2. Implementing Runnable interface
  3. Using both
  4. None
View Answer
Answer: C
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?
  1. execute()
  2. run()
  3. launch()
  4. main()
View Answer
Answer: B
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
  1. 10
  2. 12
  3. 5
  4. 8
View Answer
Answer: A

 

Q) Which method must be implemented by a Java thread?
  1. run()
  2. execute()
  3. start()
  4. None
View Answer
Answer: A

Q) Number of threads in below java program is
  1. 0
  2. 1
  3. 2
  4. 3
View Answer
Answer: C
Main program is also run as a thread. And, program has created one child thread. Hence, total 2 threads are there in the program.