Question discussion

What is the output of the following code snippet?

358839Medium DSSSB TGT Computer Science 0 replies 0 views
0
What is the output of the following code snippet?
int x = 6;
System.out.println(x++ + ++x);
  • A12
  • B14
  • C11
  • D13
Correct answer: B

Explanation

x++ gives 6 and makes x = 7. Then ++x makes x = 8 and gives 8. The sum is 6 + 8 = 14.

Discussion 0

Nobody has replied yet. Start the discussion!