Unit 4 Practice Test: Data Collections
Master AP Computer Science A Unit 4 with practice tests on 1D arrays, ArrayList, 2D arrays, and traversal algorithms. Build FRQ and MCQ Java skills.
Data Collections in AP Computer Science A
Unit 4 introduces the primary data structures tested on the AP exam. Arrays and ArrayLists are central to multiple FRQ types, and 2D array questions appear consistently. Proficiency with data collection traversal is essential for scoring well on both the MCQ and FRQ sections.
One-Dimensional Arrays
A 1D array stores a fixed-size, ordered collection of elements of the same type. AP MCQ questions test array access by index, traversal using for loops, and partial-fill patterns. FRQs may require you to write methods that search, count, or transform array elements.
ArrayList
ArrayList is a resizable list from the java.util package. Key methods tested on the AP exam include add(), get(), set(), remove(), and size(). AP questions frequently test the interaction between ArrayList index shifting and loop logic.
Two-Dimensional Arrays
2D arrays store data in a grid of rows and columns. Traversal requires nested loops — one for rows and one for columns. AP FRQ questions involving 2D arrays often ask you to process specific rows, columns, or diagonal patterns. Keeping track of which index controls rows versus columns is a critical tracing skill.
Traversal Algorithms
AP CSA tests sequential search, finding the minimum or maximum in an array, and basic sorting logic. Understanding how to implement these algorithms using loops and conditional statements is both an MCQ tracing skill and an FRQ writing skill.
Common Mistakes in Unit 4
- Index out of bounds: Accessing an array at index equal to its length — valid indices run from 0 to length–1.
- ArrayList iterator modification errors: Removing elements from an ArrayList inside a standard for loop causes index shifting, leading to skipped elements.
- Row/column confusion in 2D arrays: Swapping row and column indices when accessing a 2D array.
- Using length() instead of length: Arrays use the length field; Strings use the length() method; ArrayLists use the size() method. Mixing these is a common AP MCQ trap.
FRQ Types Covered in Unit 4
Unit 4 FRQ practice covers three primary formats: array traversal methods that compute a result, ArrayList manipulation requiring add/remove logic, and 2D array processing that requires nested loop implementation. Practicing all three formats develops the flexibility needed to handle any data-collection FRQ on exam day.