for Loops

AP Computer Science A· difficulty 4/5

<code>for (int i = 0; i < 5; i++) {} System.out.println(i);</code> will

  • A

    Print 0

  • B

    Compile error: i out of scope

    check_circle
  • C

    Print 5

  • D

    Print 4

Explanation

<code>i</code> declared inside <code>for</code> is scoped to the loop only.

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

Related questions