AP CSA FRQ Guide

2018 FRQ 3: CodeWordChecker

Write a complete CodeWordChecker class. The class stores valid length bounds and a forbidden substring, supports two constructor forms, and reports whether a candidate string satisfies all rules.

Complete Class with Legacy Interface22 minute targetclass writingconstructorsString methodslengthindexOflegacy interface

Skills Tested

What this FRQ is really practicing

class writingconstructorsString methodslengthindexOflegacy interface

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 without copying a solution

  1. 1Write the complete class header for CodeWordChecker.
  2. 2Store minimum length, maximum length, and the forbidden substring as instance variables.
  3. 3The three-parameter constructor should store the custom bounds and forbidden substring.
  4. 4The one-parameter constructor should use the default bounds described in the official prompt.
  5. 5isValid should return true only when the length is within bounds and the forbidden substring is absent.

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

Forgetting the one-parameter constructor defaults.
Using indexOf incorrectly and accepting strings that contain the forbidden text.
Checking only one length bound.
Writing a method but not the complete class.
Treating uppercase and lowercase as the same when String matching is case-sensitive.

Self Check

Review questions before you submit

Defines CodeWordChecker as a complete class implementing StringChecker.

The legacy prompt describes CodeWordChecker as a StringChecker.

Declares fields for min length, max length, and forbidden text.

The object needs to remember all three rule values.

Includes the constructor with int, int, String parameters.

This constructor sets custom bounds and the forbidden substring.

Includes the one-parameter constructor.

This constructor receives only the forbidden substring.

Uses the default length bounds in the one-parameter constructor.

The prompt supplies default minimum and maximum lengths.

Defines isValid with boolean return type and a String parameter.

This method implements the StringChecker behavior.

Checks the candidate string length.

Both the minimum and maximum bounds matter.

Rejects strings shorter than the minimum length.

Use >= min length or an equivalent false condition.

Practice Links

Where to go next