while Loops

AP Computer Science A· difficulty 2/5

What is printed?

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

  • A

    1 2 3

  • B

    Infinite loop

  • C

    0 1 2 3

  • D

    0 1 2

    check_circle

Explanation

Loops while i < 3: prints 0, 1, 2.

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

Related questions