Oracle
1Z0-809 · Question #159
1Z0-809 Question #159: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-809 to reveal the answer and full explanation for question #159. The question stem and answer options stay visible for context.
Question
Given the code fragment:
public class Test {
static int count = 0;
int i = 0;
public void changeCount() {
while (i < 5) {
count++;
i++;
}
}
public static void main(String[] args) {
Test check1 = new Test();
Test check2 = new Test();
check1.changeCount();
check2.changeCount();
System.out.print(check1.count + ":" + check2.count);
}
}
What is the result?
Options
- A10 : 10
- B5 : 10
- CCompilation fails.
- D5 : 5
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.