• 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 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<Integer> 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<String> list, String letter) {
    int count = 0;
    for (String s : list) {
        if (s.contains(letter)) {
            count++;
        }
    }
    return count;
}

Common Mistakes

  • Using == to compare Strings
  • Ignoring case sensitivity

FRQ 3 — Find First Matching Object (Easy)

Problem
Return the index of the first Student whose name matches name.

Example
["Amit", "Riya", "John"], "Riya" → 1

Approach

  • Traverse using indices
  • Use .equals() on names
  • Return index immediately

Java Solution

public int findStudent(ArrayList<Student> 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 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 index
  • Remove negatives
  • Decrement index after removal

Java Solution

public void removeNegatives(ArrayList<Integer> list) {
    for (int i = 0; i < list.size(); i++) {
        if (list.get(i) < 0) {
            list.remove(i);
            i--;
        }
    }
}

Common Mistakes

  • Forgetting i--
  • Using enhanced for-loop

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<String> 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
  • 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 list
  • Insert after match
  • Skip inserted value

Java Solution

public void insertAfter(ArrayList<String> 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
  • Not skipping inserted element

FRQ 7 — Shift List Left (Medium)

Problem
Shift all elements left by one position.

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

Approach

  • Store first element
  • Remove it
  • Add to end

Java Solution

public void shiftLeft(ArrayList<Student> list) {
    if (!list.isEmpty()) {
        Student first = list.remove(0);
        list.add(first);
    }
}

Common Mistakes

  • Forgetting empty list check

FRQ 8 — Remove Adjacent Duplicate Strings (Medium)

Problem
Remove consecutive duplicate strings.

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

Approach

  • Compare adjacent elements
  • Remove duplicates
  • Adjust index

Java Solution

public void removeAdjacentDuplicates(ArrayList<String> 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

FRQ 9 — Remove Students Below Average Score (Hard)

Problem
Remove all students scoring below the average.

Approach

  • Compute average score
  • Traverse again
  • Remove below-average students

Java Solution

public void removeBelowAverage(ArrayList<Student> 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

  • Integer division
  • Removing during enhanced for-loop

FRQ 10 — Remove Longest Strings (Hard)

Problem
Remove all strings having the maximum length.

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

Approach

  • Find max length
  • Remove matching strings

Java Solution

public void removeLongest(ArrayList<String> 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 finding max

FRQ 11 — Merge Two Sorted Integer Lists (Hard)

Problem
Merge two sorted lists into one sorted list.

Approach

  • Use two pointers
  • Compare and insert smaller value

Java Solution

public ArrayList<Integer> merge(ArrayList<Integer> a, ArrayList<Integer> b) {
    ArrayList<Integer> 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 remaining elements

FRQ 12 — Partition Students by Passing Status (Hard)

Problem
Reorder list so passing students appear first.

Approach

  • Use temporary list
  • Add passing, then failing students

Java Solution

public void partitionPassing(ArrayList<Student> list) {
    ArrayList<Student> 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 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 with previous element
  • Count changes

Java Solution

public int countUnique(ArrayList<String> 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 sorted condition

FRQ 14 — Find Student With Highest Score (Hard)

Problem
Return the student with the highest score.

Approach

  • Track best student
  • Compare scores

Java Solution

public Student findTopStudent(ArrayList<Student> list) {
    Student best = list.get(0);
    for (Student s : list) {
        if (s.getScore() > best.getScore()) {
            best = s;
        }
    }
    return best;
}

Common Mistakes

  • Returning index instead of 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 cumulative sum
  • Update list using set

Java Solution

public void runningTotal(ArrayList<Integer> 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 existing one

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