Unit 4: Data Collections
CS A · Unit 4 · Paper 1

Data Collections unit test

A test on this unit alone, marked as a percentage and a letter grade — for the test your class is actually sitting, rather than for May. Answer everything, then submit once: seeing the answer to question 3 before attempting question 4 makes the final percentage meaningless.

Each paper is built from this unit’s 63 terms and is the same for everyone, so a teacher can assign “Unit 4, Paper 1” and every student sits the identical test. Multiple choice is marked objectively; the written sections you mark yourself against the model answer and rubric.
Suggested time 31 min 28 points0/17 attempted
1

array.length

2

Building a String in a loop

3

Tracing a sorting question

4

Traversing part of a collection

5

Array parameter mutation

6

Standard algorithm: copy an array

7

Merging two sorted halves

8

Initializing an ArrayList with values

9

Comparing objects in a collection

10

Traversing an array with an indexed for loop

11

ArrayList

12

Nested collection traversal cost

Short answer 1. Define or explain: Declaring an ArrayList

3 pts

Short answer 2. Define or explain: Enhanced for loop over a 2D array

3 pts

Short answer 3. Define or explain: Off-by-one in array bounds

3 pts

Short answer 4. Define or explain: Array initializer list

3 pts

Free response

4 pts

This course has no free-response prompt tagged to this unit, so one from elsewhere in the course is used. It is still worth writing — the skill transfers.

Write a method `findLongestStreak(int[] arr)` that takes an array of integers and returns the length of the longest consecutive sequence of identical numbers. For example, if arr is {1, 2, 2, 2, 3, 3, 1}, the method should return 3.