AP CSA FRQ Guide
2026 FRQ 1: Account
Write the Account constructor, which generates an available username by appending successive integers to a requested name using a provided isAvailable helper, and write getShortenedName, which removes each hyphen and the character before it from a username.
Skills Tested
What this FRQ is really practicing
Treat these skills as the study checklist. If any tag feels shaky, review that topic before attempting the full written response.
Starter Approach
How to begin with your own plan
- 1Part A: use the provided isAvailable helper to test requestedName, and if unavailable, test requestedName + "1", requestedName + "2", and so on until an available username is found, then assign it to the instance variable.
- 2Part B: scan username and build a new string that omits every hyphen and the single character immediately before each hyphen.
Write a first attempt before revealing any solution outline. Most AP CSA FRQ progress comes from tracing your own code and finding the missing case.
Common Mistakes
Mistakes to watch for while writing
Self Check
Review questions before you submit
Calls isAvailable to test each candidate username.
Start by checking isAvailable(requestedName).
Builds new candidates by appending an integer to requestedName.
Concatenate requestedName with a counter, e.g. requestedName + count.
Repeats until an available username is found.
Use a while loop (or equivalent) that keeps trying until isAvailable returns true.
Assigns the found username to the instance variable username.
Store the final available name in username before the constructor ends.
Scans through username to check for hyphens.
Use a loop with an index over username, e.g. username.charAt(i).
Checks for the hyphen character.
Compare a character to '-'.
Skips both the hyphen and the character immediately before it.
When a hyphen is found, the previously appended character must be removed too.
Practice Links
