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); }} Prints Compiler error Prints IllegalThreadStateException is thrown Prints Prints Compiler error Prints IllegalThreadStateException is thrown Prints ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads In java a thread can be created by .......... Implementing Runnable interface. None of these Extending the thread class. Both of the above Implementing Runnable interface. None of these Extending the thread class. Both of the above ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads Which of the following constructor of class Thread is valid one? Thread(int priority) Thread(String threadName, int priority) Thread(Runnable threadOb, String threadName) None of these Thread(Runnable threadOb, int priority) Thread(int priority) Thread(String threadName, int priority) Thread(Runnable threadOb, String threadName) None of these Thread(Runnable threadOb, int priority) ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads Given the code. What will be the result?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"); }} "BeginEnd" is printed. "BeginEndRun" is printed. Compilation fails. "BeginRunEnd" is printed. An exception is thrown at runtime. "BeginEnd" is printed. "BeginEndRun" is printed. Compilation fails. "BeginRunEnd" is printed. An exception is thrown at runtime. 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 one threads that are waiting on this object's monitor Wakes up all 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 one threads that are waiting on this object's monitor Wakes up all threads that are waiting on this object's monitor ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads Analyze the following code:public abstract class Test implements Runnable{ public void doSomething() { };} The program compiles fine. None of these The program will not compile because it does not contain abstract methods. The program will not compile because it does not implement the run() method. The program compiles fine. None of these The program will not compile because it does not contain abstract methods. The program will not compile because it does not implement the run() method. ANSWER DOWNLOAD EXAMIANS APP