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 Prints Prints Compiler error IllegalThreadStateException is thrown Prints Prints Prints Compiler error IllegalThreadStateException is thrown ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads 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. } None of these Compilation fails with an error at line 5 null Compilation succeed but Runtime Exception good None of these Compilation fails with an error at line 5 null Compilation succeed but Runtime Exception good 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();}} None of these Compilation Error 0 1 0 0 None of these Compilation Error 0 1 0 0 ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads In java a thread can be created by .......... Extending the thread class. Both of the above Implementing Runnable interface. None of these Extending the thread class. Both of the above Implementing Runnable interface. None of these ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads When a class extends the Thread class ,it should override ............ method of Thread class to start that thread. run() start() go() init() run() start() go() init() ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads Analyze the following code:public abstract class Test implements Runnable{ public void doSomething() { };} None of these The program compiles fine. The program will not compile because it does not implement the run() method. The program will not compile because it does not contain abstract methods. None of these The program compiles fine. The program will not compile because it does not implement the run() method. The program will not compile because it does not contain abstract methods. ANSWER DOWNLOAD EXAMIANS APP