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 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.

ANSWER DOWNLOAD EXAMIANS APP

JAVA Threads
What notifyAll() method do?

Wakes up all threads that are waiting on this object's monitor
Wakes up one threads that are waiting on this object's monitor
None of these
Wakes up all threads that are not waiting on this object's monitor

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"); }}

"BeginEndRun" is printed.
"BeginRunEnd" is printed.
Compilation fails.
An exception is thrown at runtime.
"BeginEnd" is printed.

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(); }}

Compilation succeed but Runtime Exception
A B A B A B A B
Output order is not guaranteed
A A A A B B B B
None of these

ANSWER DOWNLOAD EXAMIANS APP