MCQs
Total Questions : 22
| Page 2 of 3 pages
Answer: Option C. -> A A A A B B B B
Answer: Option C. -> Wakes up all threads that are waiting on this object's monitor
Answer: Option C. -> 1 , 2 and 4
Question 14. What will happen when you attempt to compile and run the following code?class A implements Runnable{ public void run(){ System.out.println("run-A"); }}1. public class Test{2. public static void main(String argv[]){3. A a = new A();4. Thread t = new Thread(a);5. System.out.println(t.isAlive());6. t.start();7. System.out.println(t.isAlive());8. }9. }
Answer: Option D. -> false run-A true
Answer: Option C. -> 0 1
Answer: Option C. -> Clean compile but no output at runtime
Answer: Option D. -> synchronized
Answer: Option E. -> Prints
Question 19. What will be the output after compiling and executing the following code?public class Test implements Runnable{ public static void main(String[] args) throws InterruptedException{ Thread a = new Thread(new Test()); a.start(); System.out.print("Begin"); a.join(); System.out.print("End"); } public void run(){ System.out.print("Run"); }}
Answer: Option E. -> "BeginRunEnd" is printed.
Question 20. What is the output for the below code ?class A implements Runnable{ public void run(){ System.out.println(Thread.currentThread().getName()); }}1. public class Test{2. public static void main(String... args){3. A a = new A();4. Thread t = new Thread(a);5. t.setName("good");6. t.start();7. }8. }
Answer: Option E. -> good