JAVA Threads Which keyword when applied on a method indicates that only one thread should execute the method at a time. synchronized static final volatile native synchronized static final volatile native 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 0 0 0 1 Compilation Error None of these 0 0 0 1 Compilation Error ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads What will be the output of the following program code?public class Test implements Runnable{ public static void main(String[] args){ Thread t = new Thread(this); t.start(); } public void run(){ System.out.println("test"); }} The program does not compile because this cannot be referenced in a static method. The program compiles fine, but it does not print anything because t does not invoke the run() method None of these The program compiles and runs fine and displays test on the console. The program does not compile because this cannot be referenced in a static method. The program compiles fine, but it does not print anything because t does not invoke the run() method None of these The program compiles and runs fine and displays test on the console. ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads Which of the following constructor of class Thread is valid one? Thread(Runnable threadOb, String threadName) None of these Thread(Runnable threadOb, int priority) Thread(String threadName, int priority) Thread(int priority) Thread(Runnable threadOb, String threadName) None of these Thread(Runnable threadOb, int priority) Thread(String threadName, int priority) Thread(int priority) ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads What will happen when you attempt to compile and run the following code?class A implements Runnable{ public void run(){ System.out.println("run-A"); }}1. public class Test{2. public static void main(String argv[]){3. A a = new A();4. Thread t = new Thread(a);5. System.out.println(t.isAlive());6. t.start();7. System.out.println(t.isAlive());8. }9. } Compilation fails due to an error on line 7 None of these false run-A false false run-A true true run-A true Compilation fails due to an error on line 7 None of these false run-A false false run-A true true run-A true 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