JAVA Threads When a class extends the Thread class ,it should override ............ method of Thread class to start that thread. start() run() init() go() start() run() init() go() ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads Which keyword when applied on a method indicates that only one thread should execute the method at a time. static native volatile synchronized final static native volatile synchronized final 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(); }} 0 1 Compilation error, class A has no start method 0 0 None of these Compilation succeed but runtime exception 0 1 Compilation error, class A has no start method 0 0 None of these Compilation succeed but runtime exception ANSWER DOWNLOAD EXAMIANS APP
JAVA Threads What will happen when you attempt to compile and run the following code?1. public class Test extends Thread{2. public static void main(String argv[]){3. Test t = new Test();4. t.run();5. t.start();6. }7. public void run(){8. System.out.println("run-test");9. }10. } run-test run-test run-test None of these Compilation fails due to an error on line 7 Compilation fails due to an error on line 4 run-test run-test run-test None of these Compilation fails due to an error on line 7 Compilation fails due to an error on line 4 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"); }} 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. "BeginEndRun" is printed. "BeginRunEnd" is printed. 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(); }} "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 An exception is thrown at runtime. ANSWER DOWNLOAD EXAMIANS APP