Expressions and Assignment Statements

AP Computer Science A· difficulty 4/5

What is printed by:

<code>int x = 5; System.out.println(x++); </code></pre>

  • A

    6

  • B

    0

  • C

    Nothing

  • D

    5

    check_circle

Explanation

Post-increment returns the original value, then increments. <code>x</code> becomes 6 after, but 5 is printed.

Want 10 more like this — adaptive to your weak spots?

Related questions