Question: What is the output of the following program? class ThreadTest extends Thread { public void run ( ) { for ( int i = 0

What is the output of the following program?
class ThreadTest extends Thread {
public void run(){
for(int i =0; i <3; i++){
System.out.println("A");
System.out.println("B");
}
}
}
class ThreadDemo 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[]){
ThreadTest t1= new ThreadTest();
ThreadDemo t2= new ThreadDemo();
t1.start();
t2.start();
}
}
Question 6 options:
Will print in this order ABCD...ABCD...
Will print A B C D but we cannot predict the Order in which this will be printed.
Will print in this order AB CD AB...
Compile time Error There is no start() method.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!