• 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

  • Solve each problem first without looking at the answer
  • Compare your approach with the step-by-step solution
  • Review the “Common Mistakes” section
  • Retry the problem and apply the corrections

FRQ 1 — Count Strings Containing a Letter (Easy)

Problem

Write countContaining(ArrayList<String> list, String letter) that returns how many elements in the list contain the given letter.

Example:
[“cat”, “dog”, “car”, “tree”], letter = “a” → returns 2

Approach

  • Loop through list
  • Use contains()
  • Increase count when true

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 == for Strings
  • Not understanding case-sensitivity
  • Using indexOf incorrectly

FRQ 2 — Remove All Short Words (Medium)

Problem

Write a method removeShortWords(ArrayList<String> words, int minLength) that removes all words shorter than minLength.

Modify the list in-place.

Example:
Input: [“hi”, “apple”, “go”, “phone”], minLength = 3
Output: [“apple”, “phone”]

Approach

  • Iterate from the end to the beginning
  • Remove elements that are too short
  • Backwards loop avoids skipping elements

Java Solution

public void removeShortWords(ArrayList<String> words, int minLength) {
    for (int i = words.size() - 1; i >= 0; i--) {
        if (words.get(i).length() < minLength) {
            words.remove(i);
        }
    }
}

Common Mistakes

  • Using enhanced for-loop (causes ConcurrentModificationException)
  • Looping forward and skipping elements
  • Forgetting that remove(i) shifts the list

FRQ 3 — Double All Even Numbers (Medium)

Problem

Write a method doubleEvens(ArrayList<Integer> nums) that doubles every even number in the list.

Approach

  • Loop with index
  • Use get(i)
  • Replace with set(i, newValue)

Java Solution

public void doubleEvens(ArrayList<Integer> nums) {
    for (int i = 0; i < nums.size(); i++) {
        if (nums.get(i) % 2 == 0) {
            nums.set(i, nums.get(i) * 2);
        }
    }
}

Common Mistakes

  • Trying to modify values inside enhanced for-loop
  • Using remove inside this logic
  • Forgetting to use set()

FRQ 4 — Extract All Positive Numbers (Medium)

Problem

Write getPositives(ArrayList<Integer> nums) that returns a new ArrayList containing only the positive values.

Original list must remain unchanged.

Approach

  • Create new list
  • Add only positive numbers
  • Return new list

Java Solution

public ArrayList<Integer> getPositives(ArrayList<Integer> nums) {
    ArrayList<Integer> result = new ArrayList<>();
    for (int n : nums) {
        if (n > 0) {
            result.add(n);
        }
    }
    return result;
}

Common Mistakes

  • Modifying the original list
  • Returning null for empty lists

FRQ 5 — Find the Longest String (Hard)

Problem

Write longestString(ArrayList<String> words) that returns the longest string.
If the list is empty, return "".

Approach

  • Handle empty list case
  • Start with first element as longest
  • Compare lengths

Java Solution

public String longestString(ArrayList<String> words) {
    if (words.size() == 0) return "";

    String longest = words.get(0);

    for (String s : words) {
        if (s.length() > longest.length()) {
            longest = s;
        }
    }
    return longest;
}

Common Mistakes

  • Forgetting to check if list is empty
  • Using >= which changes which string is returned

More FRQs Coming Soon

  • Remove duplicates
  • Collapse consecutive duplicates
  • Filter words by prefix
  • List of objects (Student, Item, Score objects)
  • Merge two ArrayLists
  • Manual sorting logic

Related FRQ Pages

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

Need Help With AP CSA?

I provide 1-on-1 AP Computer Science tutoring via Zoom, including full FRQ training.

WhatsApp: +91 9853166385
Book a demo: javatutoronline.com/contact-us/

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 © 2025 JavaTutorOnline