What would be the output pe
public class Main implements Runnable
String strl, str2;
public void run()
for (int i 0; i <10; i++)
{
stri "Welcome";
str2 "To Java";
System.out.println(strl +
}
10
+ strat
public static void main(String args[])
{
Main run new Main () ;
Thread obji new Thread (run);
Thread obj2 new Thread();
objl.start();
obj2.run();
}
}
A. Prints "Welcome To Java" line-by-line for 20 times.
B. Prints "Welcome To Java" line-by-line for 10 times.
C. Prints "Welcom to Java" line-by-line for 20 times.
D. Enters into Deadlock.
E. Since obj2 did not call start() method so, throws an Exception
Share
Answer:
THIS WILL PRINT ALL THE STUFF IN A FOR LOOP