MCQs > IT & Programming > Java > Output of the given program? public class Test89 { public static void main(String[] args) { T x = new T(«X», null); x.start(); T y = new T(«Y», x); y.start(); T z = new T(«Z», y); z.start(); } } class T extends Thread { private Thread predecessor; private String name; public T(String name, Thread predecessor) { this.predecessor = predecessor; this.name = name; } public void run() { try { Thread.sleep((int)(Math.random()*89)); System.out.print(name); } catch (InterruptedException ie) { ie.printStackTrace(); } } }

Java MCQs

What is the output of the given program?

public class Test89 {

public static void main(String[] args) {

T x = new T(«X», null); x.start();

T y = new T(«Y», x); y.start();

T z = new T(«Z», y); z.start();

}

}

class T extends Thread {

private Thread predecessor;

private String name;

public T(String name, Thread predecessor) {

this.predecessor = predecessor;

this.name = name;

}

public void run() {

try {

Thread.sleep((int)(Math.random()*89));

System.out.print(name);

} catch (InterruptedException ie) {

ie.printStackTrace();

}

}

}

Answer

Correct Answer: any of the following: XYZ, XZY, YXZ, YZX, ZXY, ZYX

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