AP CSA FRQ Guide

2022 FRQ 2: Textbook

Write a complete Textbook class as a subclass of Book. Store the edition in Textbook, call the Book constructor for title and price, override the book-info method, and determine whether one textbook can substitute for another.

Complete Class and Subclassing22 minute targetclass writingconstructorsmethod overridingString methodslegacy topic

Skills Tested

What this FRQ is really practicing

class writingconstructorsmethod overridingString methodslegacy topic

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 Textbook class header as a subclass of Book.
  2. 2Store the edition number in Textbook and call the superclass constructor with title and price.
  3. 3Return the edition from getEdition.
  4. 4Override getBookInfo so it includes the superclass book info followed by the edition.
  5. 5Return true from canSubstituteFor only when titles match and this edition is greater than or equal to the other edition.

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 extends Book in the class header.
Trying to directly access private title or price fields from Book.
Forgetting to call super in the constructor.
Using == to compare book titles.
Reversing the edition comparison in canSubstituteFor.

Self Check

Review questions before you submit

Defines Textbook as a subclass of Book.

The class header needs extends Book.

Declares an int field for the edition.

Edition information belongs in Textbook.

Includes the constructor with title, price, and edition parameters.

The constructor should receive String, double, and int values.

Calls the Book constructor with title and price.

Use super(bookTitle, bookPrice) as the first constructor statement.

Stores the edition parameter in the edition field.

Assign the int constructor parameter to the Textbook field.

Defines getEdition with int return type.

This method returns the stored edition number.

Overrides getBookInfo with String return type.

Use the same method signature as Book.

Uses super.getBookInfo when building textbook info.

The title and price should stay managed by Book.

Practice Links

Where to go next