Question 1 of 25
Hints left: 3
Q1
What requires less resources?
Q2
Which of the following will ensure the thread will be in running state?
Q3
Deadlock is a situation when thread is waiting for other thread to release acquired object.
Q4
Which of these method is used to tell the calling thread to give up a monitor and go to sleep until some other thread enters the same monitor?
Q5
What will be the output of the following Java program? class newthread extends Thread { Thread t; String name; newthread(String threadname) { name = threadname; t = new Thread(this,name); t.start(); } public void run() { } } class multithreaded_programing { public static void main(String args[]) { newthread obj1 = new newthread("one"); newthread obj2 = new newthread("two"); try { Thread.sleep(1000); System.out.print(obj1.t.isAlive()); } catch(InterruptedException e) { System.out.print("Main thread interrupted"); } } }
Q6
Which of the following stops execution of a thread?
Q7
What will be the output of the following Java code? class newthread extends Thread { newthread() { super("My Thread"); start(); } public void run() { System.out.println(this); } } class multithreaded_programing { public static void main(String args[]) { new newthread(); } }
Q8
What will be the output of the following Java code? class newthread implements Runnable { Thread t; newthread() { t = new Thread(this,"My Thread"); t.start(); } public void run() { System.out.println(t.getName()); } } class multithreaded_programing { public static void main(String args[]) { new newthread(); } }
Q9
What will be the output of the following Java program? class newthread extends Thread { Thread t; newthread() { t1 = new Thread(this,"Thread_1"); t2 = new Thread(this,"Thread_2"); t1.start(); t2.start(); } public void run() { t2.setPriority(Thread.MAX_PRIORITY); System.out.print(t1.equals(t2)); } } class multithreaded_programing { public static void main(String args[]) { new newthread(); } }
Q10
What is true about time slicing?
Q11
What will be the output of the following Java code? class newthread implements Runnable { Thread t; newthread() { t1 = new Thread(this,"Thread_1"); t2 = new Thread(this,"Thread_2"); t1.start(); t2.start(); } public void run() { t2.setPriority(Thread.MAX_PRIORITY); System.out.print(t1.equals(t2)); } } class multithreaded_programing { public static void main(String args[]) { new newthread(); } }
Q12
Which of this method can be used to make the main thread to be executed last among all the threads?
Q13
What is the name of the thread in output in the following Java program? class multithreaded_programing { public static void main(String args[]) { Thread t = Thread.currentThread(); System.out.println(t.getPriority()); } }
Q14
What is the name of the thread in output in the following Java program? class multithreaded_programing { public static void main(String args[]) { Thread t = Thread.currentThread(); System.out.println(t.isAlive()); } }
Q15
Which of these keywords are used to implement synchronization? class newthread extends Thread { Thread t; String name; newthread(String threadname) { name = threadname; t = new Thread(this,name); t.start(); } public void run() { } } class multithreaded_programing { public static void main(String args[]) { newthread obj1 = new newthread("one"); newthread obj2 = new newthread("two"); try { obj1.t.wait(); System.out.print(obj1.t.isAlive()); } catch(Exception e) { System.out.print("Main thread interrupted"); } } }
Q16
Which of these statement is incorrect?
Q17
What decides thread priority?
Q18
Which of the following is a correct constructor for thread?
Q19
Which of these method wakes up the first thread that called wait()?
Q20
What will be the output of the following Java code? class newthread implements Runnable { Thread t; newthread() { t = new Thread(this,"New Thread"); t.start(); } public void run() { t.setPriority(Thread.MAX_PRIORITY); System.out.println(t); } } class multithreaded_programing { public static void main(String args[]) { new newthread(); } }
Q21
Which of these method wakes up all the threads?
Q22
Which of these method is used to begin the execution of a thread?
Q23
Thread priority in Java is?
Q24
Which of this method is used to find out that a thread is still running or not?
Q25
What will happen if two thread of the same priority are called to be processed simultaneously?