Oracle
1Z0-809 · Question #40
1Z0-809 Question #40: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-809 to reveal the answer and full explanation for question #40. The question stem and answer options stay visible for context.
Question
Given the code fragments:
class MyThread implements Runnable {
private static AtomicInteger count = new AtomicInteger (0);
public void run () {
int x = count.incrementAndGet();
System.out.print (x+" ");
}
}
and
Thread thread1 = new Thread(new MyThread());
Thread thread2 = new Thread(new MyThread());
Thread thread3 = new Thread(new MyThread());
Thread[] ta = {thread1, thread2, thread3};
for (int x= 0; x < 3; x++) {
ta[x].start();
}
Which statement is true?
Options
- AThe program prints 1 2 3 and the order is unpredictable.
- BThe program prints 1 2 3.
- CThe program prints 1 1 1.
- DA compilation error occurs.
Unlock 1Z0-809 to see the answer
You've previewed enough free 1Z0-809 questions. Unlock 1Z0-809 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.