Question 84 / 297:  What is considered an impossible output of running the following program?
public class Tester extends Thread {

int code = 9;

public void run() {

this.code = 7;

}

public static void main(String[] args) {

Tester thread = new Tester();

thread.start();

for (int i = 0; i < 5; i++) {

System.out.print(thread.code);

}

}

}

A  99777
B  97777
C  77777
D  79999
E  99999
<< First < Previous Next > Last >>
Explanation:

The thread can start running (executing run()) at any time before/within or after the loop. The possible output is 0-5 printings of "9" followed by 0-5 printings of "7". It is never possible to print "7"(s) followed by "9"(s)

Exam Home Page
Ask
Mike Wolf
Start Exam
Copy and paste the following HTML code into your website or blog.
<iframe src="https://www.jobilize.com/embed/java-certification-questions" width="600" height="600" frameborder="0" marginwidth="0" marginheight="0" scrolling="yes" style="border:1px solid #CCC; border-width:1px 1px 0; margin-bottom:5px" allowfullscreen webkitallowfullscreen mozallowfullscreen> </iframe>