All 4 CS A units
AP Computer Science A · Unit 4 of 4

Data Collections

30–40% of the exam4 lessons · 57 min

What this unit covers

The topics below follow the published CS A course framework for Unit 4. This unit is worth 30–40% of the exam, so budget your time against that rather than against how long the unit takes to teach.

1D arraysArrayList2D arraysTraversals, searching & sorting

Lessons in this unit

Formulas in Unit 4

Array length and last index
valid indices: 0 … arr.length − 1
`arr.length` is a field (no parentheses). The last usable index is one less than the length.
ArrayList essentials
list.add(x) list.get(i) list.size() list.remove(i)
Zero-based indexing. `remove(i)` deletes index i and shifts later elements left, shrinking size by 1.
2D array dimensions
rows = m.length columns = m[0].length
Access is m[row][col], both zero-based. new int[R][C] has R rows and C columns.
Find the maximum
int max = a[0]; for (int i = 1; i < a.length; i++) if (a[i] > max) max = a[i];
Seed max with the first element, then update it whenever a larger element appears. One pass finds the maximum.

What examiners penalize here

Practice CS A

Our practice bank is drawn from across the whole course rather than filtered to one unit, which is closer to how the exam asks anyway — it will not tell you which unit a question is testing.

Questions about this unit

How much of the AP Computer Science A exam is Unit 4?

Unit 4, Data Collections, is worth 30–40% of the CS A multiple-choice section according to the published course framework. Across all 4 units that makes it one of the heaviest units on the exam, and worth front-loading.

What topics are covered in CS A Unit 4?

Data Collections covers 1D arrays, ArrayList, 2D arrays and Traversals, searching & sorting.

How should I study CS A Unit 4?

Read the 4 lessons below first — about 55 minutes — then work practice questions on these topics. Finish with practice questions and read the explanation for every one you get right by elimination as well as the ones you miss.

All 4 units of AP Computer Science A

  1. Unit 1 · Using Objects and Methods
  2. Unit 2 · Selection and Iteration
  3. Unit 3 · Class Creation
  4. Unit 4 · Data Collections

Unit names, topics and exam weights follow the published College Board course framework for AP Computer Science A. AP® is a trademark registered by the College Board, which does not endorse this site.