AP Computer Science A (AP CSA) FRQ Practice

Practice released AP CSA free-response questions.

2026 AP Computer Science A 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.

Recommended time

22 minutes

Difficulty

Medium

Self-check coverage

0 / 7

Open the official prompt for the exact examples and wording. This practice page focuses on writing, self-checking, and improving your response.

Open Official Prompt

What to write

  • Part 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.
  • Part B: scan username and build a new string that omits every hyphen and the single character immediately before each hyphen.

Starter shape

public Account(String requestedName)
{
    // Write part (a) here.
}

public String getShortenedName()
{
    // Write part (b) here.
}

Common traps

  • 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.

Your response

Cleared when this page reloads. 20 words.

Rule-based feedback

This checks for common structural signals. It is not official scoring.

Looking for something else?