What is the output of the Java code? int x = 5;
What is the output of the Java code?
int x = 5;
System.out.println(x++ + ++x);
Show answerHide answer
Correct answer: (B) 12
Explanation
Java evaluates left to right: 5 (x becomes 6) + 7 = 12.
Correct answer: (B) 12
Explanation
Java evaluates left to right: 5 (x becomes 6) + 7 = 12.
This is question 141 of DSSSB TGT Computer Science Full Mock Test 3. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.