2025 AP CSA FRQ 2 - SignedText (Solution + Scoring)

FRQ Archive2025 FRQs › FRQ 2: SignedText
2025 AP CSA • Class Design

AP CSA 2025 FRQ 2: SignedText

Complete solution, scoring rubric breakdown, and walkthrough for the full class design problem with String manipulation and signature logic

9 Points Medium Unit 3
Topics Covered Class design, Constructors, Instance variables, String methods
Skills Tested Writing a complete class, substring, indexOf, equals, conditional logic with Strings
Difficulty Medium
Recommended Time 22 minutes

What This Problem Asks

2025 AP CSA FRQ 2 requires students to write the complete SignedText class from scratch, including private instance variables, a constructor, and two methods. The getSignature method builds a formatted signature from first and last names, while addSignature ensures the signature appears at the end of a text string, handling three distinct cases. This question tests class design, String operations like substring, indexOf, and equals, and multi-case conditional logic. On this page, you will find the complete Java solution, College Board scoring rubric breakdown, common mistakes to avoid, and links to the unit study guides behind the tested concepts.

What This FRQ Tests

This FRQ primarily tests concepts from Unit 3: Class Creation (writing complete classes with private instance variables, constructors, accessor methods, and encapsulation) and Unit 1: Using Objects & Methods (calling String methods with correct syntax). Unit 3 accounts for 10–18% of the AP CSA exam.

Key skills tested: Declaring a class with private fields, writing a constructor that stores parameters, using substring/indexOf/equals for String logic, implementing multi-case conditional returns.

Official Question + PDF Links

Read the complete question below, then scroll down for the solution and scoring breakdown.

Download Full FRQ PDF → Download Scoring Guidelines →

Your browser cannot display the embedded PDF. Open the PDF directly →

Timer 22:00

Strategy Video

Video Walkthrough: How to Think Through This FRQ

Watch this video before attempting the problem. It walks you through how to read the prompt, plan your class structure, and dodge the most common traps — all without revealing the final code. Try the problem yourself after watching.

Subscribe for FRQ walkthroughs

Key Information from the Prompt

The SignedText class has a constructor and two methods:

  • Constructor: Takes a first name and last name (both Strings). Last name length is always >= 1.
  • getSignature(): If first name is empty, return just the last name. Otherwise, return the first letter of the first name + “-” + the last name.
  • addSignature(String text): Three cases:
    • Signature not in text → append it to the end
    • Signature at the end → return text unchanged
    • Signature at the beginning → move it to the end

Examples from the Prompt

Object Call Returns Why
SignedText("", "Wong") getSignature() "Wong" Empty first name → last name only
SignedText("henri", "dubois") getSignature() "h-dubois" First letter + dash + last name
SignedText("GRACE", "LOPEZ") getSignature() "G-LOPEZ" Case is preserved as-is
SignedText("", "FOX") addSignature("Dear") "DearFOX" Signature not found → append
SignedText("", "FOX") addSignature("Best wishesFOX") "Best wishesFOX" Already at end → unchanged
SignedText("", "FOX") addSignature("FOXThanks") "ThanksFOX" At beginning → move to end

Write the Complete SignedText Class — 9 points

Write the complete SignedText class including: a class header, private instance variables, a constructor, getSignature(), and addSignature(String text).

Write Your Solution

Drag corner to expand ▽

Scoring Rubric (9 points)

+1 Declares class header: class SignedText
+1 Declares all appropriate private instance variable(s) and constructor initializes them using parameters
+1 Declares constructor header: SignedText(String, String)
+1 Declares both method headers: public String getSignature() and public String addSignature(String)
+1 Compares first name to the empty string
+1 Determines appropriate signature string in both cases (algorithm)
+1 Calls String methods using correct syntax throughout the class
+1 Identifies the three required cases for addSignature using appropriate conditions
+1 addSignature returns appropriate String in all three cases (algorithm)

Solution

public class SignedText
{
    private String firstName;
    private String lastName;

    public SignedText(String first, String last)
    {
        firstName = first;
        lastName = last;
    }

    public String getSignature()
    {
        String sig = "";

        if (!firstName.equals(""))
        {
            sig += firstName.substring(0, 1) + "-";
        }

        sig += lastName;
        return sig;
    }

    public String addSignature(String textStr)
    {
        String sig = getSignature();
        int index = textStr.indexOf(sig);

        if (index == -1)
        {
            return textStr + sig;
        }
        else if (index == 0)
        {
            return textStr.substring(sig.length()) + sig;
        }
        else
        {
            return textStr;
        }
    }
}

Step-by-Step: Constructor

Step 1: Declare the class with public class SignedText.

Step 2: Declare two private String instance variables for the first and last names.

Step 3: Write the constructor to assign the parameters to the instance variables. This is straightforward — just firstName = first; lastName = last;.

Step-by-Step: getSignature

Step 4: Check if firstName is empty using .equals(""). Do not use == to compare Strings in Java.

Step 5: If the first name is not empty, build the signature as: first character of firstName + "-" + lastName. Use substring(0, 1) to get the first character.

Step 6: If the first name is empty, the signature is just the lastName.

Step-by-Step: addSignature

Step 7: Call getSignature() to get the signature string. You must call the method — do not rebuild the signature logic.

Step 8: Use indexOf(sig) to find where (if anywhere) the signature appears in the text.

Step 9: Three cases:

  • indexOf returns -1: signature not found → append it to the end.
  • indexOf returns 0: signature is at the beginning → remove it from the front, append to end.
  • Otherwise: signature is already at the end → return the text unchanged.

Alternate Approach (Single Instance Variable)

public class SignedText
{
    private String signature;

    public SignedText(String first, String last)
    {
        signature = last;
        if (first.length() > 0)
        {
            signature = first.substring(0, 1) + "-" + last;
        }
    }

    public String getSignature()
    {
        return signature;
    }

    public String addSignature(String textStr)
    {
        int index = textStr.indexOf(signature);
        String result = textStr;

        if (index < 0)
        {
            result += signature;
        }
        else if (index == 0)
        {
            result = result.substring(signature.length()) + signature;
        }

        return result;
    }
}

This alternate uses a single signature field computed in the constructor. Both approaches earn full credit.

Common Mistakes to Avoid

Using == instead of .equals() for String comparison

In Java, == compares references, not content. Use .equals() to compare String values. This is one of the most common errors on the AP exam.

Wrong

if (firstName == "")

Correct

if (firstName.equals(""))
Forgetting to declare instance variables as private

The rubric specifically requires private instance variables. Omitting the access modifier loses a point.

Wrong

String firstName;
String lastName;

Correct

private String firstName;
private String lastName;
Rebuilding the signature in addSignature instead of calling getSignature()

The rubric checks that you call String methods correctly, and using getSignature() in addSignature() is the expected approach. Reimplementing the logic duplicates code and risks inconsistency.

Wrong

public String addSignature(String text)
{
    String sig = firstName.substring(0, 1) + "-" + lastName;
    // rebuilding instead of reusing

Correct

public String addSignature(String text)
{
    String sig = getSignature();
    // reuses the method
Getting the three addSignature cases wrong

The three cases are: (1) signature not in text, (2) signature at end, (3) signature at beginning. Using indexOf cleanly distinguishes all three: -1 means not found, 0 means at beginning, anything else means at end (since the prompt guarantees at most one occurrence).

Wrong

// Checking startsWith before endsWith
if (text.startsWith(sig)) { ... }
else if (text.endsWith(sig)) { ... }
// This works but is harder to get right

Correct

int index = textStr.indexOf(sig);
if (index == -1) {
    /* not found */
}
else if (index == 0) {
    /* at beginning */
}
else {
    /* at end - unchanged */
}

Exam Tips for This FRQ

Always declare instance variables as private. The rubric explicitly checks for this. Omitting it is a free point lost.
Use .equals() for all String comparisons. Never use == to compare String content in Java.
When a method you wrote is available, call it instead of reimplementing the logic. Use getSignature() inside addSignature().
indexOf is your best friend for locating substrings. It returns -1 if not found, 0 if at the start, and a positive number if found later.
Plan your class structure before writing code: list the instance variables, constructor, and method signatures first. Then fill in the logic.

Scoring Summary

Criterion What It Checks Points
Class header Declares class SignedText 1
Instance variables + constructor Private fields initialized from parameters 1
Constructor header Correct signature with two String params 1
Method headers Both methods with correct signatures 1
Empty-string check Compares first name to "" 1
Signature logic Correct string in both cases 1
String methods Correct syntax throughout 1
Three cases Identifies all three addSignature conditions 1
Returns Correct String returned in all cases 1
Total 9

Want the Complete 2025 FRQ Pack?

Get all 4 FRQs with detailed problem decomposition walkthroughs, scoring alignment, common mistake analysis, and partial credit strategies — in one downloadable PDF.

Get the 2025 FRQ Pack →

Includes deeper decomposition, partial-credit strategies, and printable walkthroughs beyond what is on this free page.

Related FRQs (Same Topic)

Class Design 2024 FRQ 2: Scoreboard — Complete class with instance variables, constructor, and methods Class Design 2023 FRQ 2: Sign — String manipulation in a class with line wrapping Class Design 2019 FRQ 2: StepTracker — Tracking state with instance variables and conditionals

Study the Concepts Behind This FRQ

This FRQ primarily tests Unit 3: Class Creation and Unit 1: Using Objects & Methods. Review the complete study guides to master writing classes from scratch, encapsulation, and String method calls.

Read Unit 3 Study Guide → Read Unit 1 Study Guide →

Struggling with FRQs? Get 1-on-1 Help

Work directly with Tanner — AP CS teacher with 11+ years experience and 1,845+ verified tutoring hours. 54.5% of students score 5s (vs. 25.5% national average).

5.0Rating (451+ reviews)
1,845+Verified Hours
54.5%Score 5s

Book a Session ($150/hr) →

5-session packages available at $125/hr. Venmo, Zelle, PayPal, or credit card.

Frequently Asked Questions

What topics does 2025 AP CSA FRQ 2 test?

FRQ 2 tests writing a complete class from scratch including private instance variables, a constructor, and two methods that use String operations like substring, indexOf, equals, and length. It aligns with Unit 3 (Class Creation) and Unit 1 (Using Objects and Methods) in the 2025-2026 AP CSA curriculum.

How many points is 2025 FRQ 2 worth?

It is worth 9 points total across the entire class: class header, instance variables and constructor, method headers, empty-string comparison, signature logic, String method usage, identifying three addSignature cases, and returning correct strings in all cases.

What is the most common mistake on this FRQ?

The most common mistakes are forgetting to declare instance variables as private, using == instead of .equals() to compare Strings, and getting the three cases in addSignature wrong. The order of checks matters: distinguish between signature-not-found, signature-at-beginning, and signature-at-end.

How long should I spend on this FRQ during the exam?

The AP CSA exam gives you 90 minutes for 4 FRQs, so approximately 22 minutes. Class design FRQs require more writing than method-only questions. Budget about 5 minutes planning your class structure, 5 minutes on the constructor and getSignature, and 12 minutes on addSignature.

Which AP CSA unit does this FRQ align with?

This FRQ primarily aligns with Unit 3 (Class Creation) for writing complete classes with constructors, instance variables, and methods. It also tests Unit 1 (Using Objects and Methods) for String method calls. Unit 3 accounts for 10–18% of the AP CSA exam.

Where can I find more FRQs like this one?

Visit the FRQs by Topic page to find all Class Design questions from 2004–2025, or browse the complete FRQ Archive.

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.