Question 141

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);
  1. A11
  2. B12
  3. C13
  4. D10
Show answerHide answer

Correct answer: (B) 12

Explanation

Java evaluates left to right: 5 (x becomes 6) + 7 = 12.

From DSSSB TGT Computer Science Full Mock Test 3

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.