Question 35Asked in DSSSB TGT Computer Science (Technical), 12 Sep 2025, Shift 2 (1:00 PM)

What is the output of the following code snippet? int x = 6;

What is the output of the following code snippet? int x = 6; System.out.println(x++ + ++x);
  1. A12
  2. B14
  3. C11
  4. D13
Show answerHide answer

Correct answer: (B) 14

Explanation

x++ gives 6 and makes x 7; ++x then makes x 8 and gives 8. So 6 + 8 = 14.

From DSSSB TGT Computer Science PYQ (Technical), 12 Sep 2025, Shift 2 (1:00 PM)

This is question 35 of DSSSB TGT Computer Science PYQ (Technical), 12 Sep 2025, Shift 2 (1:00 PM). 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.