JAVA Threads Which of the following constructor of class Thread is valid one? Thread(Runnable threadOb, int priority) None of these Thread(Runnable threadOb, String threadName) Thread(String threadName, int priority) Thread(int priority) Thread(Runnable threadOb, int priority) None of these Thread(Runnable threadOb, String threadName) Thread(String threadName, int priority) Thread(int priority) 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() 1 and 3 1 , 2 and 4 3 only None of these 1 and 3 1 , 2 and 4 3 only None of these 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(); }} An exception is thrown at runtime. "gogogo" is printed "go" is printed Compilation fails. "gogo" is printed An exception is thrown at runtime. "gogogo" is printed "go" is printed Compilation fails. "gogo" is printed ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads Analyze the following code:public abstract class Test implements Runnable{ public void doSomething() { };} The program compiles fine. The program will not compile because it does not contain abstract methods. None of these The program will not compile because it does not implement the run() method. The program compiles fine. The program will not compile because it does not contain abstract methods. None of these The program will not compile because it does not implement the run() method. 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(); } public Test(){ Thread t = new Thread(this); t.start(); } public void run(){ System.out.println("test"); }} The program has a compilation error because t is defined in both the main() method and the constructor Test(). The program compiles and runs and displays nothing. The program compiles and runs and displays test. The program compiles fine, but it does not run because you cannot use the keyword this in the constructor. The program has a compilation error because t is defined in both the main() method and the constructor Test(). The program compiles and runs and displays nothing. The program compiles and runs and displays test. The program compiles fine, but it does not run because you cannot use the keyword this in the constructor. 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); }} Compiler error Prints Prints Prints IllegalThreadStateException is thrown Compiler error Prints Prints Prints IllegalThreadStateException is thrown ANSWER DOWNLOAD EXAMIANS APP