JAVA Threads Predict the output:public class Test extends Thread{ private int i; public void run(){ i++; } public static void main(String[] args){ Test a = new Test(); a.run(); System.out.print(a.i); a.start(); System.out.print(a.i); }} Compiler error IllegalThreadStateException is thrown Prints Prints Prints Compiler error IllegalThreadStateException is thrown Prints Prints Prints ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads What notifyAll() method do? Wakes up all threads that are not waiting on this object's monitor None of these Wakes up all threads that are waiting on this object's monitor Wakes up one threads that are waiting on this object's monitor Wakes up all threads that are not waiting on this object's monitor None of these Wakes up all threads that are waiting on this object's monitor Wakes up one threads that are waiting on this object's monitor ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads What will be the output?class One extends Thread{public void run(){for(int i=0; i<2; i++){System.out.print(i);}}}public class Test{public static void main(String args[]){Test t = new Test();t.call(new One());} public void call(One o){o.start();}} 0 0 None of these 0 1 Compilation Error 0 0 None of these 0 1 Compilation Error ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads What will be output of the following program code?public class Test implements Runnable{ public void run(){ System.out.print("go"); } public static void main(String arg[]) { Thread t = new Thread(new Test()); t.run(); t.run(); t.start(); }} An exception is thrown at runtime. "gogo" is printed "gogogo" is printed "go" is printed Compilation fails. An exception is thrown at runtime. "gogo" is printed "gogogo" is printed "go" is printed Compilation fails. ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads Which of the following constructor of class Thread is valid one? Thread(int priority) Thread(Runnable threadOb, int priority) Thread(Runnable threadOb, String threadName) None of these Thread(String threadName, int priority) Thread(int priority) Thread(Runnable threadOb, int priority) Thread(Runnable threadOb, String threadName) None of these Thread(String threadName, int priority) ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads 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"); }} Compilation fails. "BeginEndRun" is printed. "BeginRunEnd" is printed. "BeginEnd" is printed. An exception is thrown at runtime. Compilation fails. "BeginEndRun" is printed. "BeginRunEnd" is printed. "BeginEnd" is printed. An exception is thrown at runtime. ANSWER DOWNLOAD EXAMIANS APP