AP Computer Science A Unit 3 ReviewClass Creation

Verified for the 2027 examCompiled by AP educators
Pep mascot
Upgrade your Fiveable account to print any study guide

Download study guides as beautiful PDFs See example

Print or share PDFs with your students

Always prints our latest, updated content

Mark up and annotate as you study

Click below to go to billing portal → update your plan → choose Yearly→ and select "Fiveable Share Plan". Only pay the difference

Plan is open to all students, teachers, parents, etc
Pep mascot
Upgrade your Fiveable account to export vocabulary

Download study guides as beautiful PDFs See example

Print or share PDFs with your students

Always prints our latest, updated content

Mark up and annotate as you study

Plan is open to all students, teachers, parents, etc

AP Computer Science A Unit 3, Class Creation, covers constructors, methods, and user-defined classes across 9 topics and makes up 10-18% of the AP exam. You'll write your own Java classes from scratch, defining instance variables, constructors, and methods to model real-world objects. AP CSA Unit 3 also gets into scope, access modifiers, class variables, and the `this` keyword.

unit 3 review

AP Computer Science A Unit 3 is where you stop just using Java classes and start writing your own. The biggest idea is abstraction, meaning you design a class that bundles an object's attributes (instance variables) and behaviors (methods) while hiding the messy internal details from the rest of the program. You'll write constructors, tell instance members apart from static ones, control access with public and private, and trace what happens when object references get passed into and out of methods. This unit makes up 10-18% of the AP exam.

What this unit covers

Designing classes with abstraction

  • Abstraction means reducing complexity by focusing on the main idea and hiding details that don't matter for the question at hand. Every class you write is an exercise in abstraction.
  • Data abstraction separates what a data type represents (a Student, a BankAccount) from how it's actually stored. You give the data a name without exposing its internal representation.
  • Procedural abstraction lets you call a method by name without knowing how it works inside. When you call deposit(50), you don't need to see the code that updates the balance.
  • Before writing code, you should be able to represent a program's design in natural language or diagrams, listing each class with all of its attributes and behaviors.
  • Program design has consequences beyond the code. System reliability means a program performs as expected under stated conditions, which is why you test with a variety of inputs. Programs built to solve a problem can also cause unintended harm to societies, economies, and cultures, and you're expected to reason about both sides.

Anatomy of a class and constructors

  • Data encapsulation keeps a class's implementation details hidden from external classes. The keyword private restricts access to the declaring class, while public allows access from outside it.
  • In this course, classes are always declared public and instance variables are declared private. Method visibility depends on whether outside code needs to call it.
  • An object's state is the set of its instance variables and their values at a given moment. A BankAccount "has a" balance, a Student "has a" name. That has-a relationship is exactly what instance variables model.
  • A constructor sets the initial state of an object by initializing every instance variable. When a constructor is called, memory is allocated for the object and a reference to that object is returned.
  • Constructor parameters carry initial values in from the caller. The standard pattern copies each parameter into the matching instance variable inside the constructor body.

Writing methods that take and return values

  • A void method performs an action but returns nothing. Its header has the keyword void before the method name.
  • A non-void method returns exactly one value, and its header lists the return type where void would go. The return expression is evaluated and its value is sent back, which is called return by value.
  • The return keyword also hands the flow of control back to wherever the method was called, so any code after a return on that path never runs.
  • When an argument is an object reference, the parameter gets a copy of the reference, not a new copy of the object. Both names point at the same object, so a method can change a mutable object's state through that reference.
  • Good practice says don't modify mutable objects passed as parameters unless the specification requires it. Graders watch for this on free-response answers.
  • Methods can also return object references, which means the caller and the method may end up sharing access to the same object.

Static members, scope, and the this keyword

  • Class variables (marked static) belong to the class itself. All objects share a single copy, and public class variables are accessed with the class name and the dot operator, like Math.PI.
  • Class methods (also static) cannot access instance variables or call instance methods unless an object is passed in as a parameter. They can freely use class variables and call other class methods.
  • A variable declared final cannot have its value modified after it's set.
  • Local variables are declared in the headers or bodies of blocks of code (including method and constructor parameters) and can only be used inside that block. They cannot be declared public or private.
  • When a local variable or parameter shares a name with an instance variable, the local one wins inside that block. This is called shadowing, and it's why this.name = name shows up in constructors.
  • Inside an instance method or constructor, this holds a reference to the current object, the one whose method is running. You can use this to disambiguate shadowed variables or to pass the current object as an argument. Class methods have no this reference because they don't belong to any object.

Unit 3, Boolean Logic & Conditional Statements at a glance

TopicBig ideaKey syntax or termWatch out for
Abstraction and program designHide details, expose the main ideaData vs. procedural abstractionDesign comes before code, in diagrams or plain language
Impact of program designPrograms affect society, economy, cultureSystem reliabilityBenefits and harms can both be unintended
Anatomy of a classEncapsulation controls what outsiders can touchpublic, privateInstance variables are always private in this course
ConstructorsSet the initial state of every instance variablepublic ClassName(params)No return type, not even void
Writing methodsDefine behaviors; return at most one valuevoid vs. return type, returnCode after a return on that path never runs
Passing object referencesParameters copy the reference, not the objectMutable objects, aliasingTwo references can point at the same object
Class variables and methodsOne shared copy per class, not per objectstatic, finalStatic methods can't touch instance variables directly
Scope and accessVariables live only where they're declaredLocal variables, shadowingParameters are local variables too
The this keywordA reference to the current objectthis.x, passing thisStatic methods have no this

Why Unit 3, Boolean Logic & Conditional Statements matters in AP CSA

This unit is the turning point of the whole course. Units 1 and 2 had you calling methods someone else wrote; from here on, you're the one designing the classes. Object-oriented design (modeling real-world entities as objects with state and behavior) is the central idea of AP CSA, and this unit is where it actually clicks.

  • The free-response section always includes a class design question, where you write a complete class from a specification. Everything in this unit (constructors, private instance variables, methods, return types) is exactly what that question grades.
  • Reference semantics, meaning the idea that variables hold references to objects rather than the objects themselves, is one of the most-tested concepts on the multiple-choice section, and this is where you learn it.
  • The social and ethical impact material connects your code to the real world. Reliability and unintended consequences show up as discussion-worthy ideas throughout the course.

How this unit connects across the course

  • Everything you learned about calling methods, constructors, and the dot operator on objects like String (Unit 1) now flips perspective. You're writing the classes that other code calls, so you finally see what's behind methods like substring and equals.
  • The selection and iteration logic you built (Unit 2) becomes the body of your methods. A method like withdraw is just an if statement wrapped in a method header, and FRQs expect you to combine both fluently.
  • Writing classes here pays off directly when you store objects in arrays and ArrayLists (Unit 4). Traversing a list of Student objects and calling their methods only makes sense once you can build the Student class yourself.

Key syntax and algorithms

  • public class ClassName { ... } declares a class; in this course, classes are always public.
  • private int count; declares a private instance variable; one copy per object, defining the object's state.
  • public ClassName(int c) { count = c; } is a constructor; it has no return type and initializes every instance variable.
  • public void reset() { ... } is a void method header; it performs an action and returns nothing.
  • public int getCount() { return count; } is a non-void method; the return type replaces void and exactly one value comes back.
  • return expression; evaluates the expression, sends the value back, and immediately exits the method.
  • private static int total; declares a class variable; one shared copy for the whole class, accessed with the class name.
  • public static final double TAX_RATE = 0.07; combines static and final for a class constant that can never change.
  • this.name = name; assigns a parameter to the instance variable it shadows; this always refers to the current object.
  • The standard constructor pattern is to take one parameter per attribute and copy each into the matching private instance variable.

Unit 3, Boolean Logic & Conditional Statements on the AP exam

This unit accounts for 10-18% of the AP exam. On the multiple-choice section, expect code-tracing questions where you determine an object's state after constructor and method calls, predict what a method returns, and reason about what happens when a mutable object is passed as a parameter (aliasing questions are a classic trap). You'll also get questions on scope, shadowing, and whether a static method can legally access an instance variable.

On the free-response section, this unit is the backbone of the class design question. You'll be given a specification in plain language and asked to write a complete class, including the header, private instance variables, a constructor that initializes all of them, and methods with correct return types. Points come from precision, so declaring instance variables private, matching method signatures exactly, and returning the right type all matter. This unit's skills also bleed into the other FRQs, since every method you write anywhere on the exam lives inside a class.

Essential questions

  • How does abstraction let programmers build complex systems without drowning in detail?
  • Why do we hide an object's data behind private access and expose behavior through public methods?
  • What actually happens in memory when an object is created or passed to a method?
  • What responsibilities do programmers have for the social and economic effects of the software they design?

Key terms to know

  • Abstraction: Reducing complexity by focusing on the main idea and hiding irrelevant details.
  • Data encapsulation: Keeping a class's implementation details hidden from external classes using access modifiers.
  • Instance variable: A variable that belongs to each individual object and defines part of its state.
  • Class variable: A static variable with one copy shared by all objects of the class.
  • Constructor: A special block of code with no return type that sets an object's initial state when it's created.
  • Object state: The set of an object's instance variables and their values at a given moment.
  • Void method: A method that performs an action but returns no value.
  • Return by value: How a non-void method sends a single evaluated value back to its caller.
  • Object reference: A value that points to an object in memory; copying it gives two names for the same object.
  • Local variable: A variable declared inside a block (including parameters) that only exists within that block.
  • Shadowing: When a local variable or parameter has the same name as an instance variable and takes priority inside its block.
  • this: A reference to the current object, available inside instance methods and constructors but not static methods.
  • final: A keyword that makes a variable's value unchangeable after it's assigned.
  • System reliability: A program's ability to perform its tasks as expected under stated conditions without failure.

Common mix-ups

  • Passing an object to a method does NOT copy the object. The parameter is a copy of the reference, so changes to the object's state through the parameter affect the original. Reassigning the parameter to a new object, though, does nothing to the caller's variable.
  • Constructors are not methods. They have no return type at all, not even void, and writing public void BankAccount() creates a useless method instead of a constructor.
  • Static methods cannot use this or touch instance variables directly. If a static method needs an object's data, the object has to be passed in as a parameter.
  • A return statement ends the method immediately. An if-else where both branches return means anything written after the if-else is unreachable, a detail multiple-choice questions love to test.