Oracle
1Z0-803 · Question #7
Given the code fragment: int a = 0; a++; System.out.println(a++); System.out.println(a); What is the result?
The correct answer is A. 1. The first println prints variable a with value 1 and then increases the variable to 2.
Using Operators and Decision Constructs
Question
Given the code fragment:
int a = 0; a++; System.out.println(a++); System.out.println(a); What is the result?
Options
- A1
- B0
- C1
- D2
How the community answered
(17 responses)- A88% (15)
- B6% (1)
- D6% (1)
Explanation
The first println prints variable a with value 1 and then increases the variable to 2.
Topics
#increment operator#post-increment#operator evaluation
Community Discussion
No community discussion yet for this question.