CommerceThreads MCQs
Practice Threads MCQs for competitive exams.
Threads MCQs
Practice questions from this topic.
What should not be done to avoid deadlock?
- A. Avoid using multiple threads
- B. Avoid hold several locks at once
- C. Execute foreign code while holding a lock
- D. Use interruptible locks
Correct Answer: C
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); } }
- A. Thread[5,main]
- B. Thread[main,5]
- C. Thread[main,0]
- D. Thread[main,5,main]
Correct Answer: D
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); } }
- A. Thread[5,main]
- B. Thread[New Thread,5]
- C. Thread[main,5,main]
- D. Thread[New Thread,5,main]
Correct Answer: D
Which function of pre defined class Thread is used to check weather current thread being checked is still running?
- A. isAlive()
- B. Join()
- C. isRunning()
- D. Alive()
Correct Answer: A
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); } }
- A. main
- B. Thread
- C. System
- D. None of the mentioned
Correct Answer: A
Which of these method of Thread class is used to find out the priority given to a thread?
- A. get()
- B. ThreadPriority()
- C. getPriority()
- D. getThreadPriority()
Correct Answer: C
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()); } }
- A. main
- B. Thread
- C. New Thread
- D. Thread[New Thread,5,main]
Correct Answer: C
What does not prevent JVM from terminating?
- A. Process
- B. Daemon Thread
- C. User Thread
- D. JVM Thread
Correct Answer: B
What is synchronization in reference to a thread?
- A. It's a process of handling situations when two or more threads need access to a shared resource
- B. It's a process by which many thread are able to access same shared resource simultaneously
- C. It's a process by which a method is able to access many different threads simultaneously
- D. It's a method that allow too many threads to access any information require
Correct Answer: A
Which of these method waits for the thread to terminate?
- A. sleep()
- B. isAlive()
- C. join()
- D. stop()
Correct Answer: C
Which of these method is used to explicitly set the priority of a thread?
- A. set()
- B. make()
- C. setPriority()
- D. makePriority()
Correct Answer: C
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); } }
- A. 4
- B. 5
- C. 0
- D. 1
Correct Answer: B