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. The program will not compile because it does not contain abstract methods. The program compiles fine. None of these 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. The program compiles fine. None of these 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 does not compile because the start() method is not defined in the Test class. The program compiles and runs fine. The program compiles, but it does not run because the start() method is not defined. The program compiles, but it does not run because the run() method is not implemented. The program does not compile because the start() method is not defined in the Test class. The program compiles and runs fine. The program compiles, but it does not run because the start() method is not defined. The program compiles, but it does not run because the run() method is not implemented. 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(); }} None of these A A A A B B B B Output order is not guaranteed A B A B A B A B Compilation succeed but Runtime Exception None of these A A A A B B B B Output order is not guaranteed A B A B A B A B Compilation succeed but Runtime Exception ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads Which of the following constructor of class Thread is valid one? Thread(Runnable threadOb, String threadName) Thread(int priority) None of these Thread(String threadName, int priority) Thread(Runnable threadOb, int priority) Thread(Runnable threadOb, String threadName) Thread(int priority) None of these Thread(String threadName, int priority) Thread(Runnable threadOb, int priority) ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads What will be the output?class A extends Thread{ public void run(){ for(int i=0; i<2; i++){ System.out.println(i); } }}public class Test{ public static void main(String argv[]){ Test t = new Test(); t.check(new A(){}); } public void check(A a){ a.start(); }} None of these 0 1 0 0 Compilation succeed but runtime exception Compilation error, class A has no start method None of these 0 1 0 0 Compilation succeed but runtime exception Compilation error, class A has no start method ANSWER DOWNLOAD EXAMIANS APP
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); }} IllegalThreadStateException is thrown Compiler error Prints Prints Prints IllegalThreadStateException is thrown Compiler error Prints Prints Prints ANSWER DOWNLOAD EXAMIANS APP