JAVA Threads Which keyword when applied on a method indicates that only one thread should execute the method at a time. final synchronized native volatile static final synchronized native volatile static ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads What will be the output after compiling and executing the following code?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"); }} "BeginEndRun" is printed. "BeginRunEnd" is printed. Compilation fails. "BeginEnd" is printed. An exception is thrown at runtime. "BeginEndRun" is printed. "BeginRunEnd" is printed. Compilation fails. "BeginEnd" is printed. An exception is thrown at runtime. 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 implement the run() method. None of these The program will not compile because it does not contain abstract methods. The program compiles fine. The program will not compile because it does not implement the run() method. None of these The program will not compile because it does not contain abstract methods. The program compiles fine. 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. "BeginEnd" is printed. "BeginRunEnd" is printed. Compilation fails. "BeginEndRun" is printed. An exception is thrown at runtime. "BeginEnd" is printed. "BeginRunEnd" is printed. Compilation fails. "BeginEndRun" is printed. 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 compiles and runs fine. The program does not compile because the start() method is not defined in the Test class. 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 compiles and runs fine. The program does not compile because the start() method is not defined in the Test class. 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 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();}} Compilation Error None of these 0 0 0 1 Compilation Error None of these 0 0 0 1 ANSWER DOWNLOAD EXAMIANS APP