Iteration in Java (AP CSA Unit 2): Building and Tracing Repeating Processes

0.0(0)
Studied by 0 people
0%Unit 2 Mastery
0%Exam Mastery
Build your Mastery score
multiple choiceAP Practice
Supplemental Materials
call kaiCall Kai
Card Sorting

1/24

Last updated 3:08 PM on 3/12/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

25 Terms

1
New cards

while loop

A control structure that repeats a block of code as long as a boolean condition remains true; in Java it is a pre-test loop.

2
New cards

pre-test loop

A loop that checks its condition before each repetition (including the first), so the body may run zero times if the condition starts false.

3
New cards

loop condition

The boolean expression in a loop that determines whether the loop continues or stops.

4
New cards

infinite loop

A loop that never terminates because its condition never becomes false (often due to missing/incorrect updates).

5
New cards

initialization (in loops)

Setting up variables before the loop starts so the loop has correct starting state.

6
New cards

update (in loops)

The change made each iteration (often to a loop control variable) that moves the program toward termination.

7
New cards

counter-controlled repetition

A loop pattern that repeats by manually updating a counter variable until a boundary is reached (can be done with while or for).

8
New cards

sentinel-controlled repetition

A loop pattern that continues until a special value (the sentinel) is encountered, commonly used when the number of inputs is unknown.

9
New cards

sentinel value

A special value used to signal “stop” in a loop (e.g., 0 to end input/summing).

10
New cards

input validation loop

A loop that repeats while input is invalid, continuing to prompt/update until the data becomes acceptable.

11
New cards

loop control variable

A variable whose value affects the loop condition and thus controls when the loop ends (e.g., i, x).

12
New cards

tracing (loops)

Step-by-step tracking of variable changes across iterations to predict final output or returned values.

13
New cards

order of statements (loop body)

The idea that statements inside a loop execute in the written sequence, which can change outcomes when variables are updated.

14
New cards

String length

The number of characters in a String, obtained with str.length(), used to set safe loop bounds.

15
New cards

substring(a, b)

A String method that returns characters from index a up to (but not including) index b.

16
New cards

single-character substring pattern

Using str.substring(i, i + 1) to get the one-character String at index i.

17
New cards

off-by-one error

A boundary mistake (often using < vs <=) that causes one extra or one fewer iteration, or index out-of-bounds.

18
New cards

out-of-bounds (String indexing)

An error caused by using an invalid index (e.g., i == str.length()) when accessing characters/substrings.

19
New cards

for loop

A loop structure that combines initialization, condition, and update in one header; ideal for counting and index traversal.

20
New cards

for-loop header

The part of a for loop written as (initialization; condition; update) that controls loop behavior.

21
New cards

for-loop execution order

Initialization runs once; then condition is checked; if true the body runs; then update runs; then condition is checked again.

22
New cards

for-to-while equivalence

The concept that any for loop can be rewritten as a while loop by separating initialization, condition, and update.

23
New cards

scope (loop variable)

Where a variable can be used; a variable declared in a for header (e.g., int i) is only accessible within the loop.

24
New cards

nested iteration

A structure where one loop is inside another; the inner loop completes all its iterations for each outer-loop iteration.

25
New cards

pairwise comparison pattern (i < j)

A nested-loop technique that starts the inner index at i + 1 to ensure i < j, avoid self-comparison, and prevent counting pairs twice.