Commerce

Threads MCQs

Practice Threads MCQs for competitive exams.

Threads MCQs

Practice questions from this topic.

What should not be done to avoid deadlock?

  1. A. Avoid using multiple threads
  2. B. Avoid hold several locks at once
  3. C. Execute foreign code while holding a lock
  4. D. Use interruptible locks
Report Error

What will be the output of the following Java code? class multithreaded_programing { public static void main(String args[]) { Thread t = Thread.currentThread(); System.out.println(t); } }

  1. A. Thread[5,main]
  2. B. Thread[main,5]
  3. C. Thread[main,0]
  4. D. Thread[main,5,main]
Report Error

What will be the output of the following Java code? class multithreaded_programing { public static void main(String args[]) { Thread t = Thread.currentThread(); t.setName("New Thread"); System.out.println(t); } }

  1. A. Thread[5,main]
  2. B. Thread[New Thread,5]
  3. C. Thread[main,5,main]
  4. D. Thread[New Thread,5,main]
Report Error

Which function of pre defined class Thread is used to check weather current thread being checked is still running?

  1. A. isAlive()
  2. B. Join()
  3. C. isRunning()
  4. D. Alive()
Report Error

What is the name of the thread in the following Java Program? class multithreaded_programing { public static void main(String args[]) { Thread t = Thread.currentThread(); System.out.println(t); } }

  1. A. main
  2. B. Thread
  3. C. System
  4. D. None of the mentioned
Report Error

Which of these method of Thread class is used to find out the priority given to a thread?

  1. A. get()
  2. B. ThreadPriority()
  3. C. getPriority()
  4. D. getThreadPriority()
Report Error

What is the priority of the thread in output in the following Java program? class multithreaded_programing { public static void main(String args[]) { Thread t = Thread.currentThread(); t.setName("New Thread"); System.out.println(t.getName()); } }

  1. A. main
  2. B. Thread
  3. C. New Thread
  4. D. Thread[New Thread,5,main]
Report Error

What does not prevent JVM from terminating?

  1. A. Process
  2. B. Daemon Thread
  3. C. User Thread
  4. D. JVM Thread
Report Error

What is synchronization in reference to a thread?

  1. A. It's a process of handling situations when two or more threads need access to a shared resource
  2. B. It's a process by which many thread are able to access same shared resource simultaneously
  3. C. It's a process by which a method is able to access many different threads simultaneously
  4. D. It's a method that allow too many threads to access any information require
Report Error

Which of these method waits for the thread to terminate?

  1. A. sleep()
  2. B. isAlive()
  3. C. join()
  4. D. stop()
Report Error

Which of these method is used to explicitly set the priority of a thread?

  1. A. set()
  2. B. make()
  3. C. setPriority()
  4. D. makePriority()
Report Error

What is the priority of the thread in the following Java Program? class multithreaded_programing { public static void main(String args[]) { Thread t = Thread.currentThread(); System.out.println(t); } }

  1. A. 4
  2. B. 5
  3. C. 0
  4. D. 1
Report Error