Skip to main content
The new Teacher Workspace is here. Your first 3 assignments are free. Try it →

AP Computer Science A Class Design FRQ Practice

27 Class Design questions written in the AP format. Pick one, read the full specification, and write your Java class.

Your first scored response is included. A plan unlocks unlimited scoring.

New to the Class Design FRQ? Read the exam guide

all units
unit 3
unit 4

27 questions

sorted by unit

String manipulation through combination and wrapping

Unit 3: Class Creation

Teacher? Assign this question to a class

start this question
  1. This question involves the TextCombiner class, which models a pair of strings that can be combined or wrapped within other strings. You will write the complete TextCombiner class, which contains a constructor and two methods.

TextCombiner objects are created by calls to a constructor with two parameters.

  • The first text segment to be stored (Precondition: The string is not null and has a length greater than 0)

  • The second text segment to be stored (Precondition: The string is not null and has a length greater than 0)

getCombinedText

Returns a string containing the two stored text segments combined according to specific rules.

  • If the last character of the first segment is equal to the first character of the second segment, the method returns the concatenation of the first segment and the substring of the second segment starting at index 1 (removing the duplicate character).

  • Otherwise, the method returns the concatenation of the first segment and the second segment.

  • The comparison of characters is case-sensitive.

A string representing the combined text.

insertInto

Returns a new string created by inserting the combined text into a wrapper string.

  • wrapper - a string into which the combined text will be inserted

  • The method first calls getCombinedText to obtain the combined string.

  • It calculates the insertion index as wrapper.length() / 2.

  • It returns a new string formed by the substring of wrapper from index 0 to the insertion index, followed by the combined string, followed by the rest of the wrapper.

The wrapper string with the combined text inserted in the middle.

Statement

Return Value

Explanation

TextCombiner t1 = new TextCombiner("dog", "gone");

t1 is initialized with "dog" and "gone".

t1.getCombinedText();

"dogone"

The last letter of "dog" ('g') matches the first letter of "gone" ('g'). They are merged.

t1.insertInto("1234");

"12dogone34"

"dogone" is inserted into "1234" at index 2 (4 / 2).

TextCombiner t2 = new TextCombiner("red", "car");

t2 is initialized with "red" and "car".

t2.getCombinedText();

"redcar"

The last letter of "red" ('d') does not match the first letter of "car" ('c'). They are concatenated normally.

t2.insertInto("[]");

"[redcar]"

"redcar" is inserted into "[]" at index 1 (2 / 2).

Write the complete TextCombiner class. Your implementation must meet all specifications and conform to the examples shown in the table.

What the Class Design FRQ asks

Class Design is FRQ 2 on the AP Computer Science A exam. From a scenario, a specification, and a table of example calls, you write a complete class: the header, private instance variables, a constructor, and at least one method.

90 min
for all four FRQs
7 points
of the section’s 25
45%
of your score, for all four FRQs
  1. Part A: The full class

    Seven one-point checks: class header, instance variables, constructor and method headers, then method logic and return values

    7 pts

How Class Design FRQ practice works

Each question follows the exam’s format, from the full prompt to a score on every part.

  1. Read the specification

    The scenario and the table of example calls and results, laid out the way the exam shows them.

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

  3. Submit for a score out of 7

    Your response is scored against the scoring guidelines written for that question. Your first score is included.

Questions about the Class Design 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.

Do I write the whole class?

Yes. Write the class header, the private instance variables, the constructor, and each method the specification asks for, fully implemented.

How is FRQ 2 different from FRQ 1?

FRQ 2 asks you to design a whole class from a specification. FRQ 1 gives you the class and asks for two methods inside it.

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.

Are these real College Board questions?

No. We wrote them in the AP format, with a specification and examples table, and wrote scoring guidelines for each one.

More AP Computer Science A practice

Methods FRQ practice

Methods and Control Structures questions with the full class and both parts.

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.

AP Computer Science A study guides

Unit-by-unit review for the whole course.

Write your first Class Design FRQ

Pick one from the list, or let us choose for you.

Teaching AP Computer Science A? Assign these Class Design FRQs to your class