AP Computer Science A Methods FRQ Practice
41 Methods and Control Structures questions written in the AP format. Pick one, read the full question, and write your Java code.
Your first scored response is included. A plan unlocks unlimited scoring.
41 questions
sorted by unit
Travel itinerary planning and time calculation
Unit 2: Selection and Iteration
This question involves planning a trip with multiple stops using the TripPlanner class. The TripPlanner class manages a travel itinerary and calculates the total travel time. You will write a constructor and a method in the TripPlanner class.
public class TripPlanner
{
private String itinerary; // To be initialized in part (a)
private int totalMinutes; // To be initialized in part (a)
/**
* Returns the name of the next destination based on the current stop.
* Returns null if there are no further destinations.
* Precondition: currentStop is a valid location name.
*/
public String getNextStop(String currentStop)
{ /* implementation not shown */ }
/**
* Returns the travel time in minutes between two locations.
* Precondition: from and to are valid location names.
*/
public int getTravelMinutes(String from, String to)
{ /* implementation not shown */ }
/**
* Constructs a TripPlanner object.
* Initializes itinerary with the departure city and totalMinutes to 0.
* Simulates the trip by repeatedly calling getNextStop until it returns null.
* Updates itinerary and totalMinutes as described in part (a).
* Precondition: departure is a non-empty string.
*/
public TripPlanner(String departure)
{ /* to be implemented in part (a) */ }
/**
* Generates and returns a ticket code based on the itinerary.
* The code consists of the first two letters of each location in the itinerary,
* converted to uppercase.
* Precondition: itinerary contains valid locations separated by " -> ".
* Each location has at least two characters.
*/
public String generateCode()
{ /* to be implemented in part (b) */ }
/* There may be instance variables, constructors, and methods
that are not shown. */
}Write the constructor for the TripPlanner class. The constructor initializes the itinerary instance variable to the departure parameter and sets totalMinutes to 0. It then builds the rest of the trip by repeatedly calling the getNextStop method. Each valid next stop returned by getNextStop should be appended to itinerary preceded by " -> ", and the travel time between the current stop and the next stop (obtained by calling getTravelMinutes) should be added to totalMinutes. The process continues until getNextStop returns null.
Example 1
| Method Call | Return Value |
|---|---|
| getNextStop("Denver") | "Chicago" |
| getTravelMinutes("Denver", "Chicago") | 120 |
| getNextStop("Chicago") | "Boston" |
| getTravelMinutes("Chicago", "Boston") | 150 |
| getNextStop("Boston") | null |
Example 2
| Method Call | Return Value |
|---|---|
| getNextStop("Miami") | "Orlando" |
| getTravelMinutes("Miami", "Orlando") | 240 |
| getNextStop("Orlando") | null |
/** * Constructs a TripPlanner object. * Initializes itinerary with the departure city and totalMinutes to 0. * Simulates the trip by repeatedly calling getNextStop until it returns null. * Updates itinerary and totalMinutes as described in part (a). * Precondition: departure is a non-empty string. */ public TripPlanner(String departure)
Write the generateCode method, which returns a string generated from the itinerary. The code is formed by taking the first two characters of each location in the itinerary, converting them to uppercase, and concatenating them. You may assume that itinerary contains location names separated by " -> " and that every location name has at least two characters.
Example 1
Example 2
/** * Generates and returns a ticket code based on the itinerary. * The code consists of the first two letters of each location in the itinerary, * converted to uppercase. * Precondition: itinerary contains valid locations separated by " -> ". * Each location has at least two characters. */ public String generateCode()
What the Methods FRQ asks
Methods and Control Structures is FRQ 1 on the AP Computer Science A exam. You write two methods, or a constructor and a method, inside a given class, using loops, conditionals, String methods, and calls to other methods in the class.
- 90 min
- for all four FRQs
- 7 points
- 4 in part A, 3 in part B
- 45%
- of your score, for all four FRQs
Part A: Loops and method calls
A method or constructor with loops or conditionals that calls methods in the class
4 pts
Part B: String methods
A method or constructor that builds or searches a String
3 pts
How Methods 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 class, the method headers, and both parts, laid out the way the exam shows them.
Write on a 22-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 7
Your response is scored against the scoring guidelines written for that question. Your first score is included.
Feedback on every part
A summary at the top tells you what to work on next. Below it, each part shows whether you earned the point and what the scoring guidelines were looking for.
Detailed Feedback
Part A: 0/1 point
Did not earn the point. You correctly initialized `playlist` to `firstSong`, but you initialized `totalDuration` to `maxMinutes`. To earn this point, you needed to initialize `totalDuration` to the duration of the first song by calling `getDuration(firstSong)`.
Part A: 1/1 point
Earned the point. You correctly updated the `playlist` string by appending the delimiter and the new song, and you updated `totalDuration` by adding the new song's duration inside the loop.
Part B: 1/1 point
Earned the point. You correctly identified and extracted the individual song titles by using the `split` method with the arrow delimiter.
Questions about the Methods 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 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.
How is FRQ 1 different from FRQ 2?
FRQ 1 gives you the class and asks for two methods, or a constructor and a method. FRQ 2 asks you to write a whole class from a specification.
Do small syntax slips cost points?
On the exam, a slip like a missing semicolon usually doesn’t cost a point when your logic is clear. Wrong method calls and wrong comparisons do.
Are these real College Board questions?
No. We wrote them in the AP format, with the same two parts, and wrote scoring guidelines for each one.
More AP Computer Science A practice
Class Design FRQ practice
Class Design questions with the full specification and examples table.
ArrayList FRQ practice
ArrayList questions with the provided classes and the method to write.
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 Methods FRQ
Pick one from the list, or let us choose for you.
Teaching AP Computer Science A? Assign these Methods FRQs to your class

