while Loops

AP Computer Science A· difficulty 4/5

<code>int i = 0; while (i++ < 3) System.out.print(i + " ");</code>

  • A

    Infinite

  • B

    0 1 2 3

  • C

    1 2 3

    check_circle
  • D

    0 1 2

Explanation

Post-increment: compares i, then increments. Body sees incremented values: 1, 2, 3.

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

Related questions