while Loops

AP Computer Science A· difficulty 2/5

int i = 10;
while (i < 5) {
  System.out.println(i);
  i++;
}
System.out.println("done");

What is printed?

  • A

    done

    check_circle
  • B

    10 done

  • C

    nothing

  • D

    10 11 12 done

Explanation

The while condition (10 < 5) is false at the start, so the loop body never executes. Only "done" prints.

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

Related questions