Question 1 of 25
Hints left: 3
Q1
What will be the output of the following Java code? class newthread extends Thread { Thread t; newthread() { t = new Thread(this,"My Thread"); t.start(); } public void run() { try { t.join() System.out.println(t.getName()); } catch(Exception e) { System.out.print("Exception"); } } } class multithreaded_programing { public static void main(String args[]) { new newthread(); } }
Q2
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 { System.out.print(obj1.t.equals(obj2.t)); } catch(Exception e) { System.out.print("Main thread interrupted"); } } }
Q3
Which function of pre defined class Thread is used to check weather current thread being checked is still running?
Q4
What is synchronization in reference to a thread?
Q5
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()); } }
Q6
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); } }
Q7
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); } }
Q8
What is multithreaded programming?
Q9
Which of these method of Thread class is used to Suspend a thread for a period of time?
Q10
Which class is used to read data from the keyboard in Java?
Q11
Which of these are types of multitasking?
Q12
Which method is used to write data to a file in Java?
Q13
Which of these method is used to explicitly set the priority of a thread?
Q14
Which of these method of Thread class is used to find out the priority given to a thread?
Q15
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); } }
Q16
What should not be done to avoid deadlock?
Q17
What is synchronization in reference to a thread?
Q18
What does not prevent JVM from terminating?
Q19
What is the purpose of the `System.out.println()` method in Java?
Q20
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); } }
Q21
Which of these method is used to implement Runnable interface?
Q22
Which of these method waits for the thread to terminate?
Q23
Which of these statements is incorrect?
Q24
How can you close a file after reading or writing in Java?
Q25
What is the default value of priority variable MIN_PRIORITY AND MAX_PRIORITY?