• Skip to main content
  • Skip to secondary menu
  • Skip to primary sidebar

JavaTutorOnline

1-on-1 Online Java Training by a Senior Software Engineer

  • Home
  • AP CSA
    • FRQ Practice
      • Arrays
      • ArrayList
      • Strings
      • 2D Arrays
  • Courses
  • Tutorials
    • Java
    • Servlets
    • Struts
    • Spring
    • Webservice
  • FAQ
  • Testimonials
  • Blog
  • CONTACT US

Arrays – FRQ Practice (AP Computer Science A)

Arrays FRQ Practice

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

Easy
Problem:

Write a method countAbove(int[] arr, int limit) that returns how many elements in arr are strictly greater than limit.

Example:

arr = [30, 35, 28, 40], limit = 30 → output = 2

Approach
  • Loop through all elements
  • Use a counter
  • Compare each value with the limit
Java Solution

public int countAbove(int[] arr, int limit) {
    int count = 0;
    for (int v : arr) {
        if (v > limit) {
            count++;
        }
    }
    return count;
}
    
Common Mistakes
  • Using >= instead of >
  • Forgetting that empty arrays return 0 automatically

FRQ 2 — First Index of Even Number

Easy
Problem:

Write firstEven(int[] nums) that returns the index of the first even number. If none exist, return -1.

Example:

[3, 5, 8, 9] → returns 2

Approach
  • Loop from the start
  • Check if each element is even
  • Return index immediately
Java Solution

public int firstEven(int[] nums) {
    for (int i = 0; i < nums.length; i++) {
        if (nums[i] % 2 == 0) {
            return i;
        }
    }
    return -1;
}
    
Common Mistakes
  • Returning the value instead of the index
  • Using <= nums.length in the loop condition

FRQ 3 — Find the Maximum Value

Easy
Problem:

Return the largest value in the array.

Example:

[4, 9, 2] → 9

Approach
  • Assume the first element is the maximum
  • Compare it with remaining elements
Java Solution

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;
}
    
Common Mistakes
  • Initializing max to 0
  • Skipping the first element

FRQ 4 — Sum of Array Elements

Easy
Problem:

Return the sum of all elements in the array.

Example:

[2, 4, 6] → 12

Approach
  • Initialize a sum variable
  • Add each element
Java Solution

public int sumArray(int[] nums) {
    int sum = 0;
    for (int n : nums) {
        sum += n;
    }
    return sum;
}
    
Common Mistakes
  • Forgetting to update the sum

FRQ 5 — Count Even Numbers

Easy
Problem:

Return how many even numbers are present in the array.

Example:

[1, 2, 4, 7] → 2

Approach
  • Check n % 2 == 0
  • Maintain a counter
Java Solution

public int countEven(int[] nums) {
    int count = 0;
    for (int n : nums) {
        if (n % 2 == 0) {
            count++;
        }
    }
    return count;
}
    
Common Mistakes
  • Checking for odd instead of even

FRQ 6 — Running Total Array

Medium
Problem:

Given an array, return a new array where each element is the sum of all previous elements including itself.

Example:

[2, 3, 5] → [2, 5, 10]

Approach
  • Use a running sum variable
  • Build a new array for output
Java Solution

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;
}
    
Common Mistakes
  • Modifying the original array
  • Forgetting empty arrays return empty arrays

FRQ 7 — Replace Negatives With Zero

Medium
Problem:

Write fixNegatives(int[] arr) to replace every negative value with 0. Modify the array directly.

Java Solution

public void fixNegatives(int[] arr) {
    for (int i = 0; i < arr.length; i++) {
        if (arr[i] < 0) {
            arr[i] = 0;
        }
    }
}
    
Common Mistakes
  • Trying to remove elements (arrays cannot shrink)
  • Using enhanced for-loop to modify values

FRQ 8 — Compute the Average

Medium
Problem:

Return the average of all values as a double.

Example:

[2, 4, 6] → 4.0

Approach
  • Compute the sum
  • Divide using type casting
Java Solution

public double average(int[] nums) {
    int sum = 0;
    for (int n : nums) {
        sum += n;
    }
    return (double) sum / nums.length;
}
    
Common Mistakes
  • Integer division instead of double division

FRQ 9 — Count Values in a Range

Medium
Problem:

Return how many values fall within [low, high] inclusive.

Example:

[3, 7, 10], low = 5, high = 10 → 2

Approach
  • Check both lower and upper bounds
  • Count qualifying values
Java Solution

public int countInRange(int[] nums, int low, int high) {
    int count = 0;
    for (int n : nums) {
        if (n >= low && n <= high) {
            count++;
        }
    }
    return count;
}
    
Common Mistakes
  • Using OR (||) instead of AND (&&)

FRQ 10 — Longest Equal Streak

Medium
Problem:

Return the length of the longest consecutive streak of equal values.

Example:

[2, 2, 3, 3, 3] → 3

Approach
  • Track current streak
  • Update maximum when values repeat
Java Solution

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;
}
    
Common Mistakes
  • Resetting the streak to 0

FRQ 11 — Shift Elements Left

Hard
Problem:

Shift all elements one position to the left, moving the first element to the end.

Example:

[1, 2, 3] → [2, 3, 1]

Approach
  • Store the first element
  • Shift remaining elements
  • Place stored value at the end
Java Solution

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;
}
    
Common Mistakes
  • Overwriting the first value before saving it

FRQ 12 — Palindrome Array Check

Hard
Problem:

Return true if the array reads the same forward and backward.

Example:

[1, 2, 2, 1] → true

Approach
  • Compare symmetric elements
Java Solution

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;
}
    
Common Mistakes
  • Incorrect index calculation

FRQ 13 — Count Unique Values (Sorted Array)

Hard
Problem:

Return how many unique values exist in a sorted array.

Example:

[1, 1, 2, 3, 3] → 3

Approach
  • Compare each value with the previous one
Java Solution

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;
}
    
Common Mistakes
  • Forgetting the array must be sorted

FRQ 14 — Find First Occurrence of Target

Hard
Problem:

Return the index of the first occurrence of a target value, or -1 if not found.

Example:

[4, 6, 8], target = 6 → 1

Approach
  • Use linear search
  • Return immediately when found
Java Solution

public int findFirst(int[] nums, int target) {
    for (int i = 0; i < nums.length; i++) {
        if (nums[i] == target) {
            return i;
        }
    }
    return -1;
}
    
Common Mistakes
  • Continuing the loop after finding the target

FRQ 15 — Longest Increasing Streak

Hard
Problem:

Return the length of the longest strictly increasing consecutive streak.

Example:

[3, 4, 5, 2, 3, 4, 6] → 4

Approach
  • Track current and longest streaks
  • Reset when order breaks
Java Solution

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);
}
    
Common Mistakes
  • 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/

Primary Sidebar

Mr Chinmay

Chinmay Patel
Online Java Tutor-Demo Class

Phone & Whatsapp +919853166385
javatution@gmail.com

Recent Posts

  • How to Learn Java in One day? | Crash Course | JavaTutorOnline
  • Constructor in Java and Overloaded Constructor Example Program
  • Important Interview Questions on Java Multithreading
  • React Spring Boot Web Services Integration
  • Spring Boot RESTful Web Services Example
  • Top Spring MVC Interview Questions and Answers for Developers
  • Top Spring Core Interview Questions and Answers for Developers
  • Host Java Web Apps for Free on Mobile with Tomcat and Termux
  • How to Deploy Java Web Application on Aws EC2 with Elastic IP
  • Simple Jsp Servlet Jdbc User Registration using Tomcat Mysql and Eclipse
Copyright © 2026 JavaTutorOnline