The exercise-1 editor asks you to loop over a data set. These six ask when a loop over a collection is the right tool and what the enhanced for gives up in exchange for its clean syntax.
Applied Practice
6 questions · scenario driven · every answer is recorded for your teacher
Question 1 of 6Analyze
A program tracks 500 temperature readings. A student proposes 500 separate variables named temp1 through temp500.
What is the decisive argument for a data set instead?
Correct. Correct. A collection gives you indexing, and indexing is what makes iteration possible. That is the whole reason the structure exists.
Incorrect. Variable names may contain digits. temp1 is perfectly legal.
Incorrect. Element access is not meaningfully faster than variable access. Speed is not the argument.
Incorrect. Memory use is roughly the same. The problem is not space.
Question 2 of 6Apply
A student writes: for (int t : temps) { t = t + 1; } and is surprised the array is unchanged.
Why did the array not change?
Incorrect. Array elements are freely modifiable through an index.
Incorrect. A standard for loop with an index works; the loop type matters only because it gives access to the index.
Incorrect. The loop executed once per element. It simply had no lasting effect.
Correct. Correct. This is the defining limitation of the enhanced for loop and the most common misuse of it.
Question 3 of 6Evaluate
A method must report the position of the first reading above 100, not just whether one exists.
Which loop form is required?
Incorrect. Both loop forms can stop early with break or a flag.
Incorrect. Readability does not help when the required value is unavailable.
Correct. Correct. Needing the index is the standard test for which loop form to reach for.
Incorrect. The enhanced for hands you the value only. Any position it reported would have to be counted manually, which is just an index by another name.
Question 4 of 6Analyze
Two programs process the same 10000 readings. One prints a running average as it goes; the other stores every reading and computes the average at the end.
What does the second program gain for its extra memory?
Incorrect. It is not strictly worse. It trades memory for the ability to revisit data.
Correct. Correct. A running statistic cannot be un-run. Keeping the set is what makes order-dependent questions answerable.
Incorrect. Both compute the average in a single pass over the same count of values.
Incorrect. Storing values does not prevent overflow; the sum can overflow either way.
Question 5 of 6Apply
A data set is described as "a collection of related values processed as a unit".
Which of these is NOT a data set in that sense?
Correct. Correct. One value is a value. There is nothing to iterate over and no collection to process as a unit.
Incorrect. An ArrayList of related names is a data set held in a resizable structure.
Incorrect. A 2D array is a data set whose elements happen to be arranged in rows and columns.
Incorrect. An array of related totals processed together is exactly a data set.
Question 6 of 6Evaluate
A student says "the enhanced for loop is always better because it is shorter and cannot go out of bounds".
What is the accurate refinement of that claim?
Incorrect. It is clearly preferable for straightforward read-only traversal, which is the common case.
Incorrect. It cannot go out of bounds. The loop manages its own traversal.
Incorrect. "Always" is what makes it wrong. The loop has a real and specific range of applicability.
Correct. Correct. Both halves matter: it genuinely removes a class of bug, and it genuinely gives up capability to do so.
Whether you're a student, parent, or teacher — I'd love to hear from you.
Just want free AP CS resources?
Enter your email below and check the subscribe box — no message needed.
Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.
Typically responds within 24 hours
✓
Message Sent!
Thanks for reaching out. I'll get back to you within 24 hours.
34.8% of Tanner’s CSP students score 5s. The national average is 9.6%.
I’m a Student
I’m a Teacher
✓Free AP CSP Big Ideas cheat sheet (PDF)
✓Daily practice questions covering all 5 Big Ideas
✓Create Task tips that actually work — from a real AP teacher
✓Free class codes with student progress tracking
✓3 full practice exams + Top 100 questions for your class
✓Create Task guidance and pseudocode reference sheets
Which AP CS exams are you prepping for?
✓
You’re in!
Your Big Ideas cheat sheet is on its way.
No thanks, I’ll figure it out myself
Avg student improvement: 2+ score levels | Real AP teacher, not just a tutor
AP Cybersecurity — National Launch 2026–27
Get Early Access to AP Cyber
AP Cyber launches nationally fall 2026. Get in early to help shape the course — start free with Unit 1 and the free teacher gradebook.
✓
You’re in — you’re on the AP Cyber early-access list!
Tanner will follow up personally within 48 hours. Your feedback will directly shape what gets built.
Step 1 of 4
Early Access — Limited Spots
Who are you?
Are you a teacher or a student?
I’m a Teacher
I’m a Student
Free to start — Unit 1 and the teacher gradebook are always free, no credit card.
Founding teachers unlock all 5 units and get direct input on what we build.
Not interested right now
Step 2 of 4
Your School
Tell us about your class
Other AP CS courses you teach
Your Situation
Tell us about yourself
Step 3 of 4
Classroom Needs
What does your classroom need? (select all that apply)
How You Study
What would help you most? (select all that apply)
Step 4 of 4
Almost Done
Where should we send your early-access details?
Free gradebook + Unit 1 | Your feedback shapes the course | Built by a real AP teacher