Back to marketplace

Unit 4: Iteration

No description yet. This curated deck is ready for daily study.

Total cards: 12•Content version: v4•Public deck•Updated: 8/1/2026

Card preview (12)

#1
Front (Question)

What is the purpose of a while loop?

Back (Answer)

A while loop is used when you need to iterate for an indefinite period of time until a certain condition is met.

#2
Front (Question)

What is the purpose of a for loop?

Back (Answer)

A for loop is used when you need to iterate a specific number of times and you know how many times you must iterate.

#3
Front (Question)

What is the difference between a for loop and a for each loop?

Back (Answer)

A general for loop has to set up a variable to increment, a condition to follow, and the actual increment itself A for each loop is more useful for arrays when the index is not needed

#4
Front (Question)

What is a nested loop?

Back (Answer)

A loop exists inside the body of another loop

#5
Front (Question)

What is the correct way to create a for loop? A. for(variable initialization, boolean expression, increment) B. for(boolean expression; variable initialization; increment) C. for(variable declaration : array name) D. for(variable initialization; boolean expression; increment)

Back (Answer)

D. for(variable initialization; boolean expression; increment) ex: for(int i = 0; i < arr.length; i++)

#6
Front (Question)

How often is the inner loop of a nested loop run? A. Infinitely B. One more time than the outer loop C. Each time the outer loop runs D. Two less times than the outer loop runs

Back (Answer)

C. Each time the outer loop runs

#7
Front (Question)

Why do we use while loops in Java? A. To break out of some block of code B. To do something if a condition is true C. To repeat some code while a condition is true D. To repeat something for a fixed number of times

Back (Answer)

C. To repeat some code while a condition is true

#8
Front (Question)

Which statement can we use inside of a loop to end it? A. System.out.println; B. break; C. SENTINEL; D. else;

Back (Answer)

B. break;

#9
Front (Question)

Indicates the number of times a statement is executed by the program.

Back (Answer)

Statement execution count

#10
Front (Question)

What is an Enhanced For Loop

Back (Answer)

A loop that is an alternate to a for or while loop that accesses each value in an array starting at the first value and proceeding in order.

#11
Front (Question)

This error occurs when we have “<=” instead of “

Back (Answer)

“off by one” errors

#12
Front (Question)

structure of a while loop

Back (Answer)

while (condition) { … }