AP Computer Science A Flashcards: Array Traversals
Written by AP Content Team, Verified for 2026 AP Exams, Last updated: May 2026
Review key ideas with interactive flashcards. This set includes 10 cards to help you master important concepts.
What is a primary goal when developing code to traverse the elements in a 1D array?
A primary goal is to access the elements in order to determine a result, such as finding a specific value or calculating a total.
Card 1 of 10
All Flashcards (10)
What is a primary goal when developing code to traverse the elements in a 1D array?
A primary goal is to access the elements in order to determine a result, such as finding a specific value or calculating a total.
What is meant by "traversing an array"?
Traversing an array is the process of using repetition statements to access all or an ordered sequence of elements within the array.
What is the key difference in how an enhanced for loop's variable gets its value compared to a standard for loop's index?
The enhanced for loop variable is assigned a copy of the element's value, while a standard for loop uses an index to directly access the element in the array.
What is the effect of assigning a new value to the enhanced for loop variable inside the loop?
Assigning a new value to the enhanced for loop variable does not change the value stored in the array because the variable holds a copy of the element.
How does an enhanced for loop access an array element during an iteration?
For each iteration, the enhanced for loop variable is assigned a copy of an element from the array without using the element's index.
Does an enhanced for loop provide access to an element's index?
No, an enhanced for loop accesses a copy of each element in sequence without using or providing access to its index.
If you need to modify the elements of an array (e.g., double each value), why is an enhanced for loop not suitable?
It is not suitable because changing the loop variable only modifies a temporary copy, not the actual element stored in the array.
What is the enhanced for loop variable?
It is a variable declared in an enhanced for loop header that is assigned a copy of an array element for each iteration of the loop.
Consider a traversal that needs to check both an element and its neighbor. Why might an enhanced for loop be a poor choice?
An enhanced for loop is a poor choice because it does not use an index, making it difficult to access other elements in the array relative to the current one.
What kind of programming structure is used to perform an array traversal?
Repetition statements, such as for loops or while loops, are used to perform array traversals by iterating through the elements.