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 IllegalThreadStateException is thrown Prints Compiler error Prints Prints IllegalThreadStateException is thrown Prints Compiler error Prints ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads Which of the following constructor of class Thread is valid one? 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) Thread(int priority) ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads Which keyword when applied on a method indicates that only one thread should execute the method at a time. volatile native static synchronized final volatile native static synchronized final ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads Analyze the following code:public class Test implements Runnable{ public static void main(String[] args){ Test t = new Test(); t.start(); } public void run() { }} The program compiles, but it does not run because the start() method is not defined. The program compiles and runs fine. The program does not compile because the start() method is not defined in the Test class. The program compiles, but it does not run because the run() method is not implemented. The program compiles, but it does not run because the start() method is not defined. The program compiles and runs fine. The program does not compile because the start() method is not defined in the Test class. The program compiles, but it does not run because the run() method is not implemented. 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(); }} Compilation fails. An exception is thrown at runtime. "gogo" is printed "go" is printed "gogogo" is printed Compilation fails. An exception is thrown at runtime. "gogo" is printed "go" is printed "gogogo" is printed ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads Analyze the following code:public abstract class Test implements Runnable{ public void doSomething() { };} The program will not compile because it does not implement the run() method. None of these The program will not compile because it does not contain abstract methods. The program compiles fine. The program will not compile because it does not implement the run() method. None of these The program will not compile because it does not contain abstract methods. The program compiles fine. ANSWER DOWNLOAD EXAMIANS APP