Welcome Guest | Sign in | Register
Threads - Discussion Page For Q.2939 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Threads > Questions and Answers

Q: What will be the output of the program?
class s1 extends Thread
{
public void run()
{
for(int i = 0; i < 3; i++)
{
System.out.println("A");
System.out.println("B");
}
}
}
class Test120 extends Thread
{
public void run()
{
for(int i = 0; i < 3; i++)
{
System.out.println("C");
System.out.println("D");
}
}
public static void main(String args[])
{
s1 t1 = new s1();
Test120 t2 = new Test120();
t1.start();
t2.start();
}
}
A. Compile time Error There is no start() method B. Will print in this order AB CD AB...
C. Will print but not be able to predict the Order D. Will print in this order ABCD...ABCD...

Answer and Explanation

Answer:Will print but not be able to predict the Order

Explanation:
We cannot predict the order in which threads are going to run.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.