
Arrays are one of the most important and frequently tested topics on the AP Computer Science A (AP CSA) exam.
They appear consistently in Free-Response Questions (FRQs) and form the foundation for looping, indexing, conditional logic, and algorithmic problem solving. This page provides high-quality, exam-style Array FRQs, written to closely match the difficulty, structure, and reasoning patterns used by the College Board.
Why Practice Arrays FRQs?
Arrays help build strong understanding of:
- Looping and iteration
- Index-based access
- Searching and counting
- Conditional logic
- Algorithmic thinking
- Common patterns like max/min, streaks, cumulative sum
Strong array logic leads to better performance on many FRQs.
How to Use This Page Effectively
- Solve each problem before viewing the solution
- Compare your logic with the model approach
- Read the Common Mistakes carefully
- Rewrite the solution on your own
This mirrors how AP CSA FRQs are graded.
FRQ 1 — Count Values Above a Threshold
Write a method countAbove(int[] arr, int limit)
that returns how many elements in arr are strictly
greater than limit.
arr = [30, 35, 28, 40], limit = 30 → output = 2
- Loop through all elements
- Use a counter
- Compare each value with the limit
public int countAbove(int[] arr, int limit) {
int count = 0;
for (int v : arr) {
if (v > limit) {
count++;
}
}
return count;
}
- Using >= instead of >
- Forgetting that empty arrays return 0 automatically
FRQ 2 — First Index of Even Number
Write firstEven(int[] nums) that returns the index of the
first even number. If none exist, return -1.
[3, 5, 8, 9] → returns 2
- Loop from the start
- Check if each element is even
- Return index immediately
public int firstEven(int[] nums) {
for (int i = 0; i < nums.length; i++) {
if (nums[i] % 2 == 0) {
return i;
}
}
return -1;
}
- Returning the value instead of the index
- Using <= nums.length in the loop condition
FRQ 3 — Find the Maximum Value
Return the largest value in the array.
[4, 9, 2] → 9
- Assume the first element is the maximum
- Compare it with remaining elements
public int findMax(int[] nums) {
int max = nums[0];
for (int i = 1; i < nums.length; i++) {
if (nums[i] > max) {
max = nums[i];
}
}
return max;
}
- Initializing max to 0
- Skipping the first element
FRQ 4 — Sum of Array Elements
Return the sum of all elements in the array.
[2, 4, 6] → 12
- Initialize a sum variable
- Add each element
public int sumArray(int[] nums) {
int sum = 0;
for (int n : nums) {
sum += n;
}
return sum;
}
- Forgetting to update the sum
FRQ 5 — Count Even Numbers
Return how many even numbers are present in the array.
[1, 2, 4, 7] → 2
- Check
n % 2 == 0 - Maintain a counter
public int countEven(int[] nums) {
int count = 0;
for (int n : nums) {
if (n % 2 == 0) {
count++;
}
}
return count;
}
- Checking for odd instead of even
FRQ 6 — Running Total Array
Given an array, return a new array where each element is the sum of all previous elements including itself.
[2, 3, 5] → [2, 5, 10]
- Use a running sum variable
- Build a new array for output
public int[] runningTotal(int[] values) {
int[] result = new int[values.length];
int sum = 0;
for (int i = 0; i < values.length; i++) {
sum += values[i];
result[i] = sum;
}
return result;
}
- Modifying the original array
- Forgetting empty arrays return empty arrays
FRQ 7 — Replace Negatives With Zero
Write fixNegatives(int[] arr) to replace every negative
value with 0. Modify the array directly.
public void fixNegatives(int[] arr) {
for (int i = 0; i < arr.length; i++) {
if (arr[i] < 0) {
arr[i] = 0;
}
}
}
- Trying to remove elements (arrays cannot shrink)
- Using enhanced for-loop to modify values
FRQ 8 — Compute the Average
Return the average of all values as a double.
[2, 4, 6] → 4.0
- Compute the sum
- Divide using type casting
public double average(int[] nums) {
int sum = 0;
for (int n : nums) {
sum += n;
}
return (double) sum / nums.length;
}
- Integer division instead of double division
FRQ 9 — Count Values in a Range
Return how many values fall within
[low, high] inclusive.
[3, 7, 10], low = 5, high = 10 → 2
- Check both lower and upper bounds
- Count qualifying values
public int countInRange(int[] nums, int low, int high) {
int count = 0;
for (int n : nums) {
if (n >= low && n <= high) {
count++;
}
}
return count;
}
- Using OR (||) instead of AND (&&)
FRQ 10 — Longest Equal Streak
Return the length of the longest consecutive streak of equal values.
[2, 2, 3, 3, 3] → 3
- Track current streak
- Update maximum when values repeat
public int longestStreak(int[] nums) {
int max = 1;
int curr = 1;
for (int i = 1; i < nums.length; i++) {
if (nums[i] == nums[i - 1]) {
curr++;
max = Math.max(max, curr);
} else {
curr = 1;
}
}
return max;
}
- Resetting the streak to 0
FRQ 11 — Shift Elements Left
Shift all elements one position to the left, moving the first element to the end.
[1, 2, 3] → [2, 3, 1]
- Store the first element
- Shift remaining elements
- Place stored value at the end
public void shiftLeft(int[] nums) {
int first = nums[0];
for (int i = 0; i < nums.length - 1; i++) {
nums[i] = nums[i + 1];
}
nums[nums.length - 1] = first;
}
- Overwriting the first value before saving it
FRQ 12 — Palindrome Array Check
Return true if the array reads the same
forward and backward.
[1, 2, 2, 1] → true
- Compare symmetric elements
public boolean isPalindrome(int[] nums) {
for (int i = 0; i < nums.length / 2; i++) {
if (nums[i] != nums[nums.length - 1 - i]) {
return false;
}
}
return true;
}
- Incorrect index calculation
FRQ 13 — Count Unique Values (Sorted Array)
Return how many unique values exist in a sorted array.
[1, 1, 2, 3, 3] → 3
- Compare each value with the previous one
public int countUnique(int[] nums) {
int count = 1;
for (int i = 1; i < nums.length; i++) {
if (nums[i] != nums[i - 1]) {
count++;
}
}
return count;
}
- Forgetting the array must be sorted
FRQ 14 — Find First Occurrence of Target
Return the index of the first occurrence
of a target value, or -1 if not found.
[4, 6, 8], target = 6 → 1
- Use linear search
- Return immediately when found
public int findFirst(int[] nums, int target) {
for (int i = 0; i < nums.length; i++) {
if (nums[i] == target) {
return i;
}
}
return -1;
}
- Continuing the loop after finding the target
FRQ 15 — Longest Increasing Streak
Return the length of the longest strictly increasing consecutive streak.
[3, 4, 5, 2, 3, 4, 6] → 4
- Track current and longest streaks
- Reset when order breaks
public int longestIncreasingStreak(int[] arr) {
int longest = 1;
int current = 1;
for (int i = 1; i < arr.length; i++) {
if (arr[i] > arr[i - 1]) {
current++;
} else {
longest = Math.max(longest, current);
current = 1;
}
}
return Math.max(longest, current);
}
- Returning 0 for single-element arrays
How Arrays Are Tested in AP CSA FRQs
Array FRQs typically assess:
- Correct indexed traversal
- Conditional counting and accumulation
- Pattern recognition (streaks, totals, comparisons)
- Edge-case handling
- Off-by-one error avoidance
Mastering these patterns makes many FRQs predictable.
Next FRQ Topics
- ArrayList FRQ Practice
- Strings FRQ Practice
- Classes & Objects FRQ Practice
- 2D Arrays FRQ Practice
- Mixed Topic FRQs
Need Structured Help With AP Computer Science A?
If you want guided, one-on-one support for AP Computer Science A—including FRQs, MCQs, debugging, and exam strategy—you can explore my dedicated tutoring program here:
AP Computer Science A tutoring support
https://www.javatutoronline.com/training-courses/ap-computer-science-tutor/