• 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

ArrayList FRQ Practice – AP Computer Science A

ArrayList_FRQ_Practice

The ArrayList is one of the most frequently tested topics on the AP Computer Science A exam.
Students must understand how to add, remove, modify, filter, and search elements inside an ArrayList — often with loops and conditions combined.

This page gives you, exam-style FRQs to strengthen your ArrayList logic and exam performance.


Why Practice ArrayList FRQs?

ArrayList FRQs commonly test:

  • Adding items
  • Removing items
  • Filtering elements
  • Counting and searching
  • Processing lists of objects
  • In-place mutation of a list
  • Iteration using for-loop or enhanced for-loop
  • Avoiding ConcurrentModification issues

Mastering these patterns will significantly improve your FRQ score.


How to Use This Page

  • Attempt each problem before viewing the solution
  • Trace index movement on paper
  • Pay attention to why i-- is required
  • Rewrite solutions from scratch
  • Focus on logic, not memorization

This mirrors how FRQs are graded by the College Board.


FRQ 1 — Count Values Above a Threshold

Easy
Problem:

Write countAbove(ArrayList<Integer> list, int limit) that returns how many values in the list are strictly greater than limit.

Example:

[10, 25, 30, 18], limit = 20 → 2

Approach
  • Traverse the list
  • Compare each value with limit
  • Increment a counter
Java Solution

public int countAbove(ArrayList list, int limit) {
    int count = 0;
    for (int v : list) {
        if (v > limit) {
            count++;
        }
    }
    return count;
}
    
Common Mistakes
  • Using >= instead of >
  • Returning the value instead of the count

FRQ 2 — Count Strings Containing a Letter

Easy
Problem:

Write countContaining(ArrayList<String> list, String letter) that returns how many strings contain letter.

Example:

[“cat”, “dog”, “car”], “a” → 2

Approach
  • Loop through the list
  • Use contains()
  • Count matches
Java Solution

public int countContaining(ArrayList list, String letter) {
    int count = 0;
    for (String s : list) {
        if (s.contains(letter)) {
            count++;
        }
    }
    return count;
}
    
Common Mistakes
  • Using == instead of .equals() for Strings
  • Ignoring case sensitivity

FRQ 3 — Find First Matching Object

Easy
Problem:

Return the index of the first Student whose name matches name. If not found, return -1.

Example:

[“Amit”, “Riya”, “John”], “Riya” → 1

Approach
  • Traverse using indices
  • Use .equals() to compare names
  • Return index immediately
Java Solution

public int findStudent(ArrayList list, String name) {
    for (int i = 0; i < list.size(); i++) {
        if (list.get(i).getName().equals(name)) {
            return i;
        }
    }
    return -1;
}
    
Common Mistakes
  • Using == for String comparison
  • Returning the object instead of the index

FRQ 4 — Remove All Negative Numbers

Medium
Problem:

Remove all negative values from the list.

Example:

[5, -2, 7, -1] → [5, 7]

Approach
  • Traverse using indices
  • Remove negatives
  • Decrement index after removal
Java Solution

public void removeNegatives(ArrayList list) {
    for (int i = 0; i < list.size(); i++) {
        if (list.get(i) < 0) {
            list.remove(i);
            i--;
        }
    }
}
    
Common Mistakes
  • Forgetting i-- after removal
  • Using enhanced for-loop while removing

FRQ 5 — Remove Short Strings

Medium
Problem:

Remove all strings shorter than minLength.

Example:

["hi", "hello", "java"], minLength = 4 → ["hello", "java"]

Approach
  • Check string length
  • Remove if condition fails
  • Adjust index
Java Solution

public void removeShortStrings(ArrayList list, int minLength) {
    for (int i = 0; i < list.size(); i++) {
        if (list.get(i).length() < minLength) {
            list.remove(i);
            i--;
        }
    }
}
    
Common Mistakes
  • Skipping elements after removal
  • Comparing Strings instead of lengths

FRQ 6 — Insert After Target Word

Medium
Problem:

Insert toAdd immediately after every occurrence of target.

Example:

["a", "b", "a"], target="a", add="x" → ["a","x","b","a","x"]

Approach
  • Traverse the list
  • Insert after match
  • Skip inserted value
Java Solution

public void insertAfter(ArrayList list, String target, String toAdd) {
    for (int i = 0; i < list.size(); i++) {
        if (list.get(i).equals(target)) {
            list.add(i + 1, toAdd);
            i++;
        }
    }
}
    
Common Mistakes
  • Infinite loop due to missing index increment
  • Not skipping the inserted element

FRQ 7 — Shift List Left

Medium
Problem:

Shift all elements one position to the left.

Example:

[A, B, C] → [B, C, A]

Approach
  • Store the first element
  • Remove it
  • Add it to the end
Java Solution

public void shiftLeft(ArrayList list) {
    if (!list.isEmpty()) {
        Student first = list.remove(0);
        list.add(first);
    }
}
    
Common Mistakes
  • Forgetting to check for empty list

FRQ 8 — Remove Adjacent Duplicate Strings

Medium
Problem:

Remove all consecutive duplicate strings from the list.

Example:

["a", "a", "b", "b"] → ["a", "b"]

Approach
  • Compare each element with the previous one
  • Remove duplicates
  • Adjust index after removal
Java Solution

public void removeAdjacentDuplicates(ArrayList list) {
    for (int i = 1; i < list.size(); i++) {
        if (list.get(i).equals(list.get(i - 1))) {
            list.remove(i);
            i--;
        }
    }
}
    
Common Mistakes
  • Comparing wrong indices
  • Forgetting to decrement index

FRQ 9 — Remove Students Below Average Score

Hard
Problem:

Remove all students whose score is below the class average.

Approach
  • Compute the average score
  • Traverse the list again
  • Remove below-average students
Java Solution

public void removeBelowAverage(ArrayList list) {
    int total = 0;
    for (Student s : list) {
        total += s.getScore();
    }
    double avg = (double) total / list.size();

    for (int i = 0; i < list.size(); i++) {
        if (list.get(i).getScore() < avg) {
            list.remove(i);
            i--;
        }
    }
}
    
Common Mistakes
  • Using integer division for average
  • Removing elements in enhanced for-loop

FRQ 10 — Remove Longest Strings

Hard
Problem:

Remove all strings that have the maximum length in the list.

Example:

["hi","hello","java"] → ["hi"]

Approach
  • Find the maximum string length
  • Traverse again and remove matching strings
Java Solution

public void removeLongest(ArrayList list) {
    int max = list.get(0).length();
    for (String s : list) {
        max = Math.max(max, s.length());
    }

    for (int i = 0; i < list.size(); i++) {
        if (list.get(i).length() == max) {
            list.remove(i);
            i--;
        }
    }
}
    
Common Mistakes
  • Removing while calculating max length

FRQ 11 — Merge Two Sorted Integer Lists

Hard
Problem:

Merge two sorted integer lists into a single sorted list.

Approach
  • Use two pointers
  • Compare and insert the smaller value
  • Add remaining elements
Java Solution

public ArrayList merge(ArrayList a, ArrayList b) {
    ArrayList result = new ArrayList<>();
    int i = 0, j = 0;

    while (i < a.size() && j < b.size()) {
        if (a.get(i) <= b.get(j)) result.add(a.get(i++));
        else result.add(b.get(j++));
    }

    while (i < a.size()) result.add(a.get(i++));
    while (j < b.size()) result.add(b.get(j++));

    return result;
}
    
Common Mistakes
  • Forgetting to add remaining elements

FRQ 12 — Partition Students by Passing Status

Hard
Problem:

Reorder the list so that all passing students appear before failing students.

Approach
  • Create a temporary list
  • Add passing students first
  • Add failing students next
Java Solution

public void partitionPassing(ArrayList list) {
    ArrayList temp = new ArrayList<>();

    for (Student s : list)
        if (s.isPassing()) temp.add(s);

    for (Student s : list)
        if (!s.isPassing()) temp.add(s);

    list.clear();
    list.addAll(temp);
}
    
Common Mistakes
  • Modifying the original list during traversal

FRQ 13 — Count Unique Strings (Sorted List)

Hard
Problem:

Return the number of unique strings in a sorted list.

Approach
  • Compare each element with the previous one
  • Count changes
Java Solution

public int countUnique(ArrayList list) {
    if (list.isEmpty()) return 0;

    int count = 1;
    for (int i = 1; i < list.size(); i++) {
        if (!list.get(i).equals(list.get(i - 1))) {
            count++;
        }
    }
    return count;
}
    
Common Mistakes
  • Forgetting the list must be sorted

FRQ 14 — Find Student With Highest Score

Hard
Problem:

Return the Student with the highest score.

Approach
  • Track the best student
  • Compare scores
Java Solution

public Student findTopStudent(ArrayList list) {
    Student best = list.get(0);
    for (Student s : list) {
        if (s.getScore() > best.getScore()) {
            best = s;
        }
    }
    return best;
}
    
Common Mistakes
  • Returning the index instead of the object

FRQ 15 — Running Total of Integers

Hard
Problem:

Convert the list into a running total list.

Example:

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

Approach
  • Maintain a cumulative sum
  • Update the list using set()
Java Solution

public void runningTotal(ArrayList list) {
    int sum = 0;
    for (int i = 0; i < list.size(); i++) {
        sum += list.get(i);
        list.set(i, sum);
    }
}
    
Common Mistakes
  • Creating a new list instead of modifying the original

Related FRQ Pages

  • Arrays FRQs
  • Strings FRQs
  • 2D Arrays FRQs
  • Mixed FRQs
  • Full Mock FRQ Set

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