MCQs > IT & Programming > Java > Output of the following code? public class Test extends Thread { private int value; public Test(int value) { this.value = value; } public static void main(String[] args) { Test t1 = new Test(1); Test t2 = new Test(2); Test t3 = new Test(3); t1.start(); t2.start(); t3.start(); } @Override public void run() { for (inti = 0; i< 3; i++) { System.out.println('Thread ' + value + ' with value ' + i + ' Started'); try { sleep(100); } catch (InterruptedException ex) { Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex); } System.out.println('Thread ' + value + ' with value '+ i + ' Completed'); } } }

Java MCQs

What will be the output of the following code? public class Test extends Thread { private
int value; public Test(int value) { this.value = value; } public static void main(String[] 
args) { Test t1 = new Test(1); Test t2 = new Test(2); Test t3 = new Test(3); t1.start();
t2.start(); t3.start(); } @Override public void run() { for (inti = 0; i< 3; i++) {
System.out.println("Thread " + value + " with value " + i + " Started"); try { sleep(100); }
catch (InterruptedException ex) { 
Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex); }
System.out.println("Thread " + value + " with value " + i + " Completed"); } } }

Answer

Correct Answer: The output cannot be predicted.

Explanation:

Note: This Question is unanswered, help us to find answer for this one

Java Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

Java Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it