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 Prints Prints IllegalThreadStateException is thrown Prints Compiler error Prints Prints IllegalThreadStateException is thrown Prints 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() init() go() run() start() init() go() 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"); }} An exception is thrown at runtime. "BeginRunEnd" is printed. "BeginEndRun" is printed. "BeginEnd" is printed. Compilation fails. An exception is thrown at runtime. "BeginRunEnd" is printed. "BeginEndRun" is printed. "BeginEnd" is printed. Compilation fails. 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 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. None of these The program compiles fine. The program will not compile because it does not implement the run() method. ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads Predict the output:class A implements Runnable{ public void run(){ try{ for(int i=0;i<4;i++){ Thread.sleep(100); System.out.println(Thread.currentThread().getName()); } }catch(InterruptedException e){ } }}public class Test{ public static void main(String argv[]) throws Exception{ A a = new A(); Thread t = new Thread(a, "A"); Thread t1 = new Thread(a, "B"); t.start(); t.join(); t1.start(); }} Compilation succeed but Runtime Exception A A A A B B B B None of these Output order is not guaranteed A B A B A B A B Compilation succeed but Runtime Exception A A A A B B B B None of these Output order is not guaranteed A B A B A B A B ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads Which of the following are methods of the Thread class?1) yield()2) sleep(long msec)3) go()4) stop() None of these 1 and 3 1 , 2 and 4 3 only None of these 1 and 3 1 , 2 and 4 3 only ANSWER DOWNLOAD EXAMIANS APP