Threads Questions and Answers

Take Exam

Threads in Java enable concurrent execution of multiple tasks, improving program efficiency and responsiveness. This concept is frequently tested in programming questions and answers and Java MCQs during placement drives by TCS, Infosys, and Wipro. Understanding thread creation, synchronization, and lifecycle is crucial for handling multitasking in software applications. Practicing Java programming interview questions with answers on threads enhances students’ understanding of concurrency, helping them tackle real-world programming challenges confidently. Knowledge of threads also plays a vital role in acing technical interviews and coding assessments.

Threads

Showing 10 of 15 questions

11. Which method registers a thread in a thread scheduler?

  • run();
  • construct();
  • start();
  • register();
Show Answer Report

12. Assume the following method is properly synchronized and called from a thread A on an object B: wait(2000); After calling this method, when will the thread A become a candidate to get another turn at the CPU?

  • After thread A is notified, or after two seconds.
  • After the lock on B is released, or after two seconds.
  • Two seconds after thread A is notified.
  • Two seconds after lock B is released.
Show Answer Report

13. Which of the following will not directly cause a thread to stop?

  • notify()
  • wait()
  • InputStream access
  • sleep()
Show Answer Report

14. Which class or interface defines the wait(), notify(),and notifyAll() methods?

  • Object
  • Thread
  • Runnable
  • Class
Show Answer Report

15. public class MyRunnable implements Runnable {     public void run()     {         // some code here     } } which of these will create and start this thread?

  • new Runnable(MyRunnable).start();
  • new Thread(MyRunnable).run();
  • new Thread(new MyRunnable()).start();
  • new MyRunnable().start();
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test