Question: Predict the output for the following code. class Task extends Thread { public void run ( ) { System.out.print ( Task ) ;

Predict the output for the following code.
class Task extends Thread {
public void run(){
System.out.print("Task ");
}
}
public class Main {
public static void main(String[] angs){
Task t1= new Task();
Task t2= new Task();
t1.start();
t2.start();
System.out.print("Main ");
}
}
The output may vary across multiple runs.
Main Task Main Task
Main Task Task
Task Task Main
Predict the output for the following code. class

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 Programming Questions!