AP Computer Science A ArrayList FRQ Practice
26 Data Analysis with ArrayList questions written in the AP format. Pick one, read the full question, and write your Java method.
Your first scored response is included. A plan unlocks unlimited scoring.
26 questions
sorted by unit
Temperature averaging with conditional filtering criteria
Unit 4: Data Collections
- The DailyReading class represents weather data collected on a single day. A partial declaration of the DailyReading class is shown below.
public class DailyReading
{
/**
* Returns the temperature in degrees Fahrenheit
*/
public double getTemperature()
{ /* implementation not shown */ }
/**
* Returns the wind speed in miles per hour
*/
public double getWindSpeed()
{ /* implementation not shown */ }
/**
* Returns true if rain was recorded, false otherwise
*/
public boolean isRaining()
{ /* implementation not shown */ }
/* There may be instance variables, constructors, and
methods that are not shown. */
}public class WeatherStation
{
/** The list of daily weather readings */
private ArrayList<DailyReading> readings;
/**
* Returns the average temperature of readings that meet the specified criteria.
* Precondition: minWind >= 0.0
* Postcondition: Returns the average temperature of readings where:
* - The wind speed is greater than or equal to minWind
* - AND (requireRain is false OR isRaining() is true)
* Returns 0.0 if no readings meet the criteria.
*/
public double averageTempWithCondition(boolean requireRain, double minWind)
{ /* to be implemented */ }
/* There may be instance variables, constructors, and methods
that are not shown. */
}Write the WeatherStation method averageTempWithCondition. This method calculates and returns the average temperature of the valid readings in the readings list. A reading is considered valid if it meets the wind speed requirement (at least minWind) and the rain requirement (if requireRain is true, the reading must be raining; if requireRain is false, the rain status does not matter).
Suppose readings contains the following five DailyReading objects.
Index | 0 | 1 | 2 | 3 | 4 |
|---|---|---|---|---|---|
Temperature | 70.0 | 80.0 | 60.0 | 90.0 | 65.0 |
Wind Speed | 10.0 | 5.0 | 15.0 | 20.0 | 12.0 |
Is Raining | true | false | true | false | true |
Call: averageTempWithCondition(true, 11.0)
Return Value: 62.5
Explanation: The method considers only readings where isRaining() is true AND wind speed is >= 11.0. Index 0 fails the wind condition (10.0 < 11.0). Index 1 and 3 fail the rain condition. Index 2 (Wind 15.0, Rain true) and Index 4 (Wind 12.0, Rain true) are valid. The average of their temperatures (60.0 and 65.0) is 62.5.
Complete method averageTempWithCondition.
/**
* Returns the average temperature of readings that meet the specified criteria.
* Precondition: minWind >= 0.0
* Postcondition: Returns the average temperature of readings where:
* - The wind speed is greater than or equal to minWind
* - AND (requireRain is false OR isRaining() is true)
* Returns 0.0 if no readings meet the criteria.
*/
public double averageTempWithCondition(boolean requireRain, double minWind)What the ArrayList FRQ asks
Data Analysis with ArrayList is FRQ 3 on the AP Computer Science A exam. You write one method that loops through an ArrayList of objects, filters them by one or more conditions, and returns a result like a count, sum, average, or maximum.
- 90 min
- for all four FRQs
- 5 points
- the fewest of the four FRQs
- 45%
- of your score, for all four FRQs
Part A: One method
Five one-point checks, such as traversing the list, conditions on its objects, tracking a result, and the return value
5 pts
How ArrayList FRQ practice works
Each question follows the exam’s format, from the full prompt to a score on every part.
Read the full question
The provided classes, the ArrayList, and the method you write, laid out the way the exam shows them.
Write on a 23-minute timer
A pace that fits all four questions into the 90-minute section. Pause it or turn it off, and your response saves as you go.
Submit for a score out of 5
Your response is scored against the scoring guidelines written for that question. Your first score is included.
Questions about the ArrayList FRQ
How many responses can I get scored?
You can read every question without a plan. Your first scored response is included. A plan unlocks unlimited scoring.
Can I use brackets to get elements from the list?
No. This question uses an ArrayList, so access elements with get() and size(), or an enhanced for loop. Bracket syntax only works on arrays.
Do I build the ArrayList myself?
No. The question gives you the list, as an instance variable or a parameter. You loop through it, call methods on its objects, and return the result.
How is FRQ 3 different from FRQ 4?
FRQ 3 works with an ArrayList and is worth 5 points. FRQ 4 works with a 2D array, usually with nested loops, and is worth 6.
Can I type Java in the editor?
Yes. Type your code the way you would on the digital exam. The Java Quick Reference is available while you write.
More AP Computer Science A practice
Methods FRQ practice
Methods and Control Structures questions with the full class and both parts.
Class Design FRQ practice
Class Design questions with the full specification and examples table.
2D Array FRQ practice
2D Array questions with the full class and the method to write.
AP Computer Science A FRQs
Every FRQ type for AP Computer Science A, with practice for each.
Write your first ArrayList FRQ
Pick one from the list, or let us choose for you.
Teaching AP Computer Science A? Assign these ArrayList FRQs to your class
