while Loops

AP Computer Science A· difficulty 4/5

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

  • A

    0 1 2

  • B

    1 2 3

  • C

    0 1

  • D

    1 2

    check_circle

Explanation

Pre-increment first: i=1, condition 1<3 true, prints 1; i=2 prints 2; i=3 condition false, stop.

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

Related questions