while Loops

AP Computer Science A· difficulty 4/5

What does this print?

<code>for (int i = 0; i < 5; i++) { if (i == 3) break; System.out.print(i); } </code></pre>

  • A

    012

    check_circle
  • B

    0123

  • C

    0124

  • D

    01234

Explanation

Break at i=3 before print → 0, 1, 2.

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

Related questions