Oracle
1Z0-819 · Question #1
Given: public class Test { public static void main(String[] args) { int x; int y = 5; if (y > 2) { x = ++y; } else { y++; } System.out.print(x + " " + y); } } What is the result?
The correct answer is A. compilation error. See the full explanation below for the reasoning.
Question
Given:
public class Test {
public static void main(String[] args) {
int x;
int y = 5;
if (y > 2) {
x = ++y;
} else {
y++;
}
System.out.print(x + " " + y);
}
}
What is the result?
Options
- Acompilation error
- B0 5
- C6 13
- D5 12
How the community answered
(40 responses)- A78% (31)
- B15% (6)
- C3% (1)
- D5% (2)
Community Discussion
No community discussion yet for this question.