Skip Top Navigation Bar

FRQ 2 Class Design

In FRQ 2: Class Design, you are expected to write a class that meets the given specification. The question might require you to use inheritance and extend a given class.

You will be provided with a description of the class that you will have to write as well as a table that represents the use of the class and the expected result. In some cases, you will be provided with a helper class.

As always:

Some more specific tips for approaching FRQ 2: Class Design are as follows:

Look closely as the provided table.

You will gain a better understanding of constructor parameters and instance variables as well as method return types and their parameters by looking at the examples. You can use this to glean the number of constructors and methods that are required.

You may need more instance variables than your constructor has parameters.

Often, there are additional instance variable than just the constructor parameters. Let's look at 2024 #2 more closely. In reading the bulleted paragraphs, we learn that we need a way to determine which team has the current turn and we need to keep scores for both of the teams. So this class has 5 instance variables. Two String objects for the team names, a variable to determine the team currently playing, and two int variables for the score. These 3 additional variables will need initial values provided in the constructor.

Only write what you are required to write.

You may have been trained that you need to have a multiple constructors, such as every class needs to have a default constructor. And that you should have accessor and mutator methods for all your instance variables. These are great rules for the real world, but for the AP CSA exam, please, please, please, ONLY write the constructor and methods that are required. You could lose points for doing more than you are supposed to do if it causes a unintended side effect.

Know the basic structure of a class.

You will need to have a header, private instance variables, a constructor and methods. There is a basic formula that you can and should follow to maximize your number of points. If you forget, you should look at the other provided classes in the FRQ section. Chances are you can get some tips from those questions as well. Here is a basic outline of a class to follow:

public class ClassName {
   //instance variables
   private type name;

   //constructor
   public ClassName (type param1, type param2, ...) { 
      //body
   }

   public returnType methodName (type param1, type param2...) {
       //body
   }
}

Just because you are given a class doesn't mean you are extending it.

Sometimes you will be given a helper class. This class could be included because you need to create an instance variable of that type or it could be provided because you need to extend this class. The is-a test is a good one for inheritance. Let's look at an example or two.

More Resources