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.

Methods and Control Structures22 minute targetconstructorsloopsString methodshelper methodssubstring

Skills Tested

What this FRQ is really practicing

constructorsloopsString methodshelper methodssubstring

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

  1. 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.
  2. 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

Only checking isAvailable(requestedName) once and never trying numbered variations.
Off-by-one errors when appending the integer suffix, such as starting at 0 instead of 1.
Removing the hyphen but forgetting to also remove the character directly before it.
Rebuilding the result with string concatenation but forgetting that removing "the character before it" means deleting the last character already added to the result, not skipping a character in the source string.

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

Where to go next