Unit 2 · Selection and Iteration
For Loops
Practice mode with 15 Java-focused questions, immediate answer checks, and explanations.
What for loops covers
A for loop packages initialization, a test condition, and an update into one header. The initialization runs once, the condition is checked before every iteration including the first, and the update runs after each body execution. A loop from 0 while i < n runs exactly n times. The enhanced for loop iterates over every element without an index and cannot be used to assign new values into an array.
Where students lose points
Iteration counting is where points disappear. Changing < to <= adds one iteration, and starting at 1 instead of 0 removes one. Students also assume the update runs before the body, which shifts every traced value by one step. With the enhanced for loop, they assume assigning to the loop variable modifies the array, which it does not.
How it shows up on the AP exam
Unit 2 iteration, and among the most heavily tested topics on the whole exam. Nearly every FRQ requires at least one correct loop header, and an off-by-one bound usually costs the traversal point outright.
For practice use only.
For Loops MCQ Practice
AP CSA for loop practice: counting iterations, tracing loop variables, off-by-one bounds, and enhanced for loop behavior on the exam.
Answered 0 of 15
Choose one answer.
Which option matches the complete output produced by this segment?
public class ForLoopsContext
{
public static void runExample()
{
for (int i = 0; i < 4; i++)
{
System.out.print(i);
}
}
public static void main(String[] args)
{
runExample();
}
}