AP exam review verified for 2027

AP Computer Science A Unit 3 Review: Class Creation

Review AP CSA Unit 3 to build the skills for designing and writing your own Java classes from scratch. This unit covers everything from abstraction and encapsulation to constructors, methods, static members, scope, and the this keyword.

Use the topic guides, practice questions, and FRQ practice available on Fiveable to work through every concept in this unit.

What is AP Computer Science A unit 3?

Unit 3 is where AP CSA shifts from using existing Java classes to building your own. You define the attributes and behaviors of objects, control what outside code can see, and write the constructors and methods that make objects work. This unit carries 10-18% of the exam weight and appears directly in free-response questions that ask you to write or complete a class.

Unit 3 is about creating Java classes. You declare private instance variables, write public constructors to initialize them, and define methods that expose or modify object state. You also learn when to use static members, how scope determines which variable a name refers to, and how this references the current object.

Abstraction drives class design

Data abstraction gives a data type a name without exposing how it is stored. Procedural abstraction gives a process a name so callers do not need to know the implementation. Together they let you design a class by listing attributes and behaviors before writing a single line of code.

Encapsulation protects object state

Declaring instance variables private and providing public accessor and mutator methods keeps implementation details hidden. Outside classes interact with your object only through the public interface, so you can change internal representation without breaking other code.

Static members belong to the class, not objects

A static variable is shared by every object of the class. A static method runs without a specific object and cannot access instance variables unless passed an object. Access static members using the class name and the dot operator, such as ClassName.field.

Classes model real-world entities and extend Java's power

Every class you write is a new data type. By combining private data, a public constructor, and well-named methods, you create objects that accurately represent ideas from a bank account to a student record. This capability is what allows programs to have broad impacts on society, economies, and cultures, and it is the foundation for Unit 4's data collections.

AP Computer Science A unit 3 topics

3.1

Abstraction and Program Design

Data abstraction names a type without exposing storage details. Procedural abstraction names a process through a method. Use both to design a class by listing attributes and behaviors before writing code.

open guide
3.2

Impact of Program Design

Programs affect society, the economy, and culture. Maximize reliability through testing, recognize unintended harms, and follow open-source and intellectual property rules when reusing code.

open guide
3.3

Anatomy of a Class

A Java class has a public class header, private instance variables, and public constructors and methods. The keywords public and private control access and enforce encapsulation.

open guide
3.4

Constructors

A constructor initializes all instance variables when an object is created with new. If no constructor is provided, Java supplies default values. Copy mutable parameters to prevent aliasing.

open guide
3.5

Methods: How to Write Them

Void methods perform actions without returning a value. Non-void methods return a single value by value. Accessor methods read state; mutator methods update it. Primitives passed to methods are copied, so the original never changes.

open guide
3.6

Methods: Passing and Returning References of an Object

Passing an object copies the reference, not the object. The method can modify the original object through that shared reference. Returning an object reference exposes the original, not a new copy.

open guide
3.7

Class Variables and Methods

Static variables are shared by all objects of a class. Static methods belong to the class and cannot access instance variables without receiving an object parameter. Use final to declare constants.

open guide
3.8

Scope and Access

Local variables and parameters exist only in their declaring block. When a local name matches an instance variable name, the local name wins inside that block. Use this to reach the instance variable.

open guide
3.9

this Keyword

this refers to the current object inside any instance method or constructor. Use this.field to resolve shadowing, and pass this as an argument to give another method access to the current object. Static methods have no this.

open guide
practice snapshot

Hardest AP Computer A unit 3 topics

This snapshot uses Fiveable practice activity to show where students tend to miss questions and which review moves are worth prioritizing first.

58%average MCQ accuracy

Across 4.0k multiple-choice practice attempts for this unit.

4.0kMCQ attempts

Practice activity included in this snapshot.

Unit 3 review notes

3.1

Abstraction and Program Design

Abstraction reduces complexity by focusing on the main idea and hiding irrelevant details. Before writing code, you can design a class by listing its attributes (data it stores) and behaviors (actions it can perform). UML class diagrams and natural-language descriptions are both valid design tools on the AP exam.

  • Data abstraction: Gives a data type a name without revealing how it is stored internally. An instance variable is one form: it has a name and type but hides its memory representation.
  • Procedural abstraction: Gives a process a name through a method so callers use the method without knowing its implementation. Changing the method body does not affect callers as long as the signature stays the same.
  • Attribute: A piece of data defined in a class outside any method. Instance variables are attributes whose values are unique to each object.
  • Behavior: What an object can do, defined by its methods. Listing behaviors during design maps directly to the methods you will write.
  • Method decomposition: Breaking a complex task into smaller helper methods, each with a single clear purpose, to improve readability and reuse.
Can you list the attributes and behaviors for a class like BankAccount or Student before writing any Java code?
Abstraction typeWhat it namesWhat it hides
Data abstractionA variable or data typeHow the data is stored in memory
Procedural abstractionA method or processThe implementation steps inside the method
3.2

Impact of Program Design

Writing a class is not just a technical act. Programs affect society, the economy, and culture in both intended and unintended ways. Reliability and legal compliance are responsibilities every programmer carries.

  • System reliability: A program's ability to perform its tasks as expected under stated conditions without failure. Testing with a variety of inputs, including edge cases, improves reliability.
  • Unintended harmful effects: Programs built to solve one problem can cause harm beyond their intended use. Algorithmic bias and privacy violations are common examples.
  • Open source: Code published and freely available for use without requiring permission or payment. Reusing code that is not open source requires obtaining permission and often purchasing a license.
  • Intellectual property: Legal rights protecting original software code. Incorporating unlicensed code without permission is a legal violation.
What is the difference between open-source code and proprietary code in terms of what a programmer is allowed to do with it?
Code typePermission needed?Cost possible?
Open sourceNoNo
Proprietary / not open sourceYesOften yes
3.3

Class Anatomy and Constructors

A Java class has a public class header, private instance variables, and public constructors. The constructor sets the initial state of an object by assigning values to every instance variable. When new is called, memory is allocated and a reference to the new object is returned.

  • Data encapsulation: Keeping implementation details hidden by declaring instance variables private and exposing state only through public methods.
  • Constructor: A special block with the class name and no return type that initializes instance variables when an object is created with new.
  • Default values: When no constructor is provided, Java initializes int and double to 0, boolean to false, and object references to null.
  • Mutable parameter copy: When a constructor receives a mutable object as a parameter, it should store a copy, not the original reference, to prevent outside code from altering the object's state.
  • Constructor header: The declaration line specifying the access modifier, the class name as the constructor name, and the parameter list. No return type appears here.
Write the constructor header and instance variable declarations for a class called Movie with a String title and an int year.
MemberAccess modifierPurpose
Instance variableprivateStores per-object state
ConstructorpublicInitializes instance variables when object is created
Accessor methodpublicReturns a copy of an instance variable's value
Mutator methodpublicUpdates an instance variable's value
3.5

Writing Methods and Passing References

Methods define what objects can do. Void methods perform actions without returning a value. Non-void methods evaluate a return expression and hand back a single value. Primitives are passed by value, so the original argument never changes. Object references are also passed by value, but because the parameter holds a copy of the reference, the method can still modify the original object's state through that shared reference.

  • Return by value: A non-void method evaluates its return expression and sends the result back to the caller. Code after a return statement in the same block never executes.
  • Accessor method: A public non-void method that returns a copy of an instance variable's value, allowing outside classes to read state without direct access to the private field.
  • Mutator method: A public void method that updates an instance variable, giving outside classes a controlled way to change object state.
  • Object reference parameter: When an object is passed to a method, the parameter receives a copy of the reference. The method can call methods on the object and change its state, but reassigning the parameter does not affect the original variable.
  • Side effect: An action a method performs beyond returning a value, such as printing output or modifying an instance variable. Mutator methods intentionally produce side effects.
If a method receives an int parameter and doubles it, does the original int variable in the caller change? What if the parameter is an ArrayList?
Parameter typeWhat is copiedCan method change original?
Primitive (int, double, boolean)The value itselfNo
Object referenceThe reference (memory address)Yes, through the shared reference
3.7

Static Variables and Methods

Static members belong to the class itself, not to any individual object. A static variable has one shared copy across all objects. A static method runs without a specific object instance and cannot access instance variables or call instance methods unless an object is passed in as a parameter.

  • Class variable (static field): Declared with the static keyword. All objects share one copy. Accessed outside the class as ClassName.variableName.
  • Class method (static method): Declared with static. Can access class variables and call other static methods, but cannot use this or access instance variables directly.
  • final keyword: When a variable is declared final, its value cannot be changed after initialization. Combined with static, it creates a class-level constant such as static final double PI = 3.14159.
  • Dot operator with class name: Public static members are accessed using ClassName.member rather than through an object reference, because they belong to the class.
Why can a static method not call an instance method directly, and how would you work around that restriction?
Member typeKeywordOne copy perCan access instance variables?
Instance variable(none)ObjectYes
Class variablestaticClassNo (it is one itself)
Instance method(none)Called on objectYes
Class methodstaticCalled on classNo, unless passed an object
3.8

Scope, Access, and the this Keyword

Scope determines where a variable name can be used. Local variables and parameters exist only inside the block where they are declared. When a local variable or parameter shares a name with an instance variable, the local name takes priority inside that block. The this keyword resolves the conflict by explicitly referring to the current object's instance variable.

  • Local variable: Declared inside a method, constructor, or block. Only accessible within that block. Cannot be declared public or private.
  • Variable shadowing: When a parameter or local variable has the same name as an instance variable, the local name is used inside that scope, hiding the instance variable.
  • this keyword: Inside an instance method or constructor, this holds a reference to the current object. Use this.fieldName to access an instance variable when a parameter shadows it.
  • this as argument: You can pass this as an argument in a method call to give another method a reference to the current object.
  • No this in static methods: Static methods have no associated object, so the this keyword is not available inside them.
In a constructor with a parameter named title that shadows an instance variable also named title, what does this.title = title accomplish?
Variable typeDeclared whereScopeAccess modifiers allowed?
Instance variableClass body, outside methodsEntire classYes (public/private)
Local variableInside a method or blockThat block onlyNo
ParameterMethod or constructor headerThat method or constructor onlyNo

Practice AP Computer Science A unit 3 questions

Try AP-style multiple-choice questions and written prompts after you review the notes.

Example AP-style MCQs

open all practice
MCQ

AP-style practice question

Question

A WeatherStation class processes an array of daily temperatures. It needs to identify the longest streak of consecutive days above freezing, calculate the average temperature during that specific streak, and format a final report string. Which procedural abstraction design best manages complexity and promotes code reuse?

A public method that calls private helper methods to find the streak, calculate the average, and format the final temperature report.

A single public method that sequentially finds the streak, calculates the average, and formats the final temperature report directly.

A private method that calls public helper methods to find the streak, calculate the average, and format the final temperature report.

Three separate public methods that outside classes must call sequentially to find the streak, calculate the average, and format reports.

MCQ

AP-style practice question

Question

A researcher is investigating a telehealth platform's automated video system for accessibility barriers. They want to determine if the system disproportionately drops connections for patients residing in rural zip codes compared to urban zip codes. Each patient and session has a unique ID. The following datasets are available:

  • Dataset 1: Patient ID, Age Group, Primary Language Spoken
  • Dataset 2: Patient ID, Zip Code, Internet Service Provider
  • Dataset 3: Zip Code, Geographic Classification (Urban/Rural)
  • Dataset 4: Session ID, Patient ID, Connection Status (Completed/Dropped)

Which combination of datasets enables the researcher to draw a conclusion?

Datasets 2, 3, and 4, to connect the dropped sessions with the patients and rural zip codes.

Datasets 1, 2, and 4, to connect the dropped sessions with the patients and spoken languages.

Datasets 1, 3, and 4, to connect the dropped sessions with the languages and rural zip codes.

Datasets 1, 2, and 3, to connect the spoken languages with the patients and rural zip codes.

Example FRQs

open all FRQs
FRQ

Payroll calculation system for employees

2. This question involves the PayCalculator class, which represents a payroll calculation system for an employee. You will write the complete PayCalculator class, which contains a constructor and two methods. PayCalculator objects are created by calls to a constructor with two parameters.

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

  • The first parameter is a double that represents the hourly pay rate in dollars. (Precondition: Assume that this value will be greater than 0.0.)

  • The second parameter is a double that represents the tax rate as a decimal (e.g., 0.15 for 15%). (Precondition: Assume that this value will be between 0.0 and 1.0 inclusive.)

calculateGrossPay

The PayCalculator class contains a calculateGrossPay method, which calculates the total pay before taxes based on the number of hours worked.

  • The method takes a single double parameter representing the number of hours worked. Assume this value is greater than or equal to 0.0.

  • Employees are paid at the hourly pay rate for the first 40 hours worked.

  • Any hours worked beyond 40 hours are considered overtime and are paid at 1.5 times the hourly pay rate.

  • The method returns the calculated gross pay as a double.

Returns the calculated gross pay as a double.

getPayStub

The PayCalculator class contains a getPayStub method, which generates a summary string of the pay and taxes.

  • The method takes a single double parameter representing the number of hours worked.

  • The method calculates the gross pay based on the hours worked.

  • The method calculates the tax amount by multiplying the gross pay by the tax rate.

  • The method calculates the net pay by subtracting the tax amount from the gross pay.

  • The method returns a formatted String containing the gross pay and net pay.

  • The returned string must be in the format "Gross: $G, Net: $N", where G is the gross pay and N is the net pay.

Returns a formatted String "Gross: $G, Net: $N".

Statement

Return Value (blank if no value)

Explanation

PayCalculator p1 = new PayCalculator(20.0, 0.1);

PayCalculator p1 is constructed with a rate of $20.00/hr and a 10% tax rate.

double g1 = p1.calculateGrossPay(30.0);

600.0

30 hours * 20.0/hr=20.0/hr = 600.0.

String s1 = p1.getPayStub(30.0);

"Gross: $600.0, Net: $540.0"

Gross is $600.0. Tax is $600.0 * 0.1 = $60.0. Net is $540.0.

double g2 = p1.calculateGrossPay(50.0);

1100.0

40 hours * 20.0=20.0 = 800.0. 10 overtime hours * (20.01.5)=20.0 * 1.5) = 300.0. Total = $1100.0.

String s2 = p1.getPayStub(50.0);

"Gross: $1100.0, Net: $990.0"

Gross is $1100.0. Tax is $1100.0 * 0.1 = $110.0. Net is $990.0.

PayCalculator p2 = new PayCalculator(15.0, 0.2);

PayCalculator p2 is constructed with a rate of $15.00/hr and a 20% tax rate.

String s3 = p2.getPayStub(40.0);

"Gross: $600.0, Net: $480.0"

40 hours * 15.0=15.0 = 600.0. Tax is 600.00.2=600.0 * 0.2 = 120.0. Net is $480.0.

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

Key terms

TermDefinition
attributeData stored in a class as an instance variable, representing a property unique to each object.
behaviorWhat an object can do, defined by the methods of its class.
constructor headerThe declaration line of a constructor specifying its access modifier, the class name as the constructor name, and the parameter list. No return type is included.
object referenceA value that holds the memory address of an object, allowing a variable to access that object's state and methods.
instance methodA method that belongs to an object and is called on a specific instance using the dot operator. It can access instance variables and the this keyword.
side effectAn action a method performs beyond returning a value, such as modifying an instance variable or printing output. Mutator methods intentionally produce side effects.
variable shadowingWhen a local variable or parameter shares a name with an instance variable, the local name is used inside that block, hiding the instance variable. Use this.fieldName to access the instance variable.
open sourceSoftware code published and freely available for use, modification, and distribution without requiring permission or payment from the original author.
intellectual propertyLegal rights protecting original software code. Reusing code that is not open source requires obtaining permission and often a license.
object compositionA design pattern where a class stores references to objects of other classes as instance variables, representing a has-a relationship.
dot operatorThe operator (.) used to access methods and variables of a class or object, placed between the class name or object reference and the member name.
early returnA return statement inside a conditional or loop that exits the method before all remaining code executes. Any code after the return in the same block is unreachable.
cachingStoring a computed value in an instance variable to avoid recalculation. Can produce incorrect results if the underlying data changes and the cached value is not updated.

Common unit 3 mistakes

Giving constructors a return type

A constructor has no return type, not even void. Writing public void ClassName() is a method, not a constructor, and the object's instance variables will never be initialized by it.

Forgetting that primitives are passed by value

Changing a primitive parameter inside a method does not affect the original argument. Students often expect the caller's variable to update, but it never does for int, double, or boolean.

Assuming static methods can access instance variables

A static method has no object context. Calling an instance variable or instance method directly inside a static method causes a compile error. You must pass an object as a parameter first.

Shadowing an instance variable without using this

In a constructor like public Movie(String title), writing title = title assigns the parameter to itself. The instance variable never gets set. Use this.title = title to fix it.

Returning a direct reference to a mutable private field

An accessor that returns this.myList hands outside code a reference to the actual private list. The caller can then modify it, breaking encapsulation. Return a copy instead.

How this unit shows up on the AP exam

Free-response class writing tasks

AP CSA free-response questions frequently ask you to write or complete a class. You may need to declare private instance variables, write a constructor that initializes them, and write accessor or mutator methods. Errors in constructor syntax (such as adding a return type) or failing to use this when a parameter shadows an instance variable are penalized.

Tracing method calls with primitives and references

Multiple-choice questions often present a method that receives a primitive or an object reference and ask what value a variable holds after the call. The key skill is knowing that primitives are copied (original unchanged) while object references share the same object (original can change through the reference).

Identifying static versus instance member behavior

Questions test whether you can identify compile errors or incorrect output caused by calling instance methods from a static context, accessing a static variable through an object reference instead of the class name, or modifying a final variable. Know the rules for what static methods can and cannot access.

Final unit 3 review checklist

  • Design a class using abstractionList all attributes (instance variables) and behaviors (methods) for a class before writing code. Know the difference between data abstraction and procedural abstraction.
  • Write a complete class with proper access controlDeclare instance variables private, the class public, constructors public, and methods public or private as needed. Confirm that encapsulation is maintained.
  • Write constructors that fully initialize object stateEvery instance variable should receive a value in the constructor. Know default values (0, 0.0, false, null) and when they apply. Copy mutable parameters to avoid aliasing.
  • Write and trace void and non-void methodsIdentify return types, trace return by value, and confirm that code after a return statement is unreachable. Distinguish accessor from mutator methods.
  • Trace reference passing and identify side effectsKnow that primitives are copied and object references are copied but still point to the original object. Identify when a method modifies the caller's object through a shared reference.
  • Use static correctlyAccess static members with the class name. Know that static methods cannot use this or access instance variables directly. Declare constants with static final.
  • Resolve scope and shadowing with thisIdentify which variable a name refers to in a given block. Use this.fieldName to access an instance variable when a parameter shadows it. Confirm that this is unavailable in static methods.

How to study unit 3

Start with abstraction and class design (3.1-3.2)Read the topic guides for 3.1 and 3.2. Practice listing attributes and behaviors for a class like Student or Car in plain language before writing any Java. Review the social and legal responsibilities covered in 3.2, including open-source rules and system reliability.
Build a complete class with encapsulation (3.3-3.4)Write a class from scratch with private instance variables and a public constructor. Check that every instance variable is initialized in the constructor. Practice with the topic guides for 3.3 and 3.4, and use available practice questions to test your constructor syntax.
Write and trace methods with primitives and references (3.5-3.6)Work through the topic guides for 3.5 and 3.6. Write accessor and mutator methods, then trace what happens when primitives versus object references are passed. Use the 20 available FRQ practice items to practice writing methods in a class context.
Add static members and understand scope (3.7-3.8)Read the topic guides for 3.7 and 3.8. Add a static counter variable to a class and write a static method that accesses it. Then trace code with local variables that shadow instance variables and identify which variable each name refers to.
Solidify the this keyword and do a full unit review (3.9)Read the topic guide for 3.9. Rewrite a constructor that has shadowing issues using this. Then review all nine topic guides as a unit, work through remaining practice questions, and use the AP score calculator to estimate where you stand.

More ways to review

Topic study guides

Open the individual guides for Unit 3 when you want a closer review of one topic.

browse guides

FRQ practice

Practice free-response reasoning and compare your answer with scoring guidance.

practice FRQs

Cheatsheets

Use unit cheatsheets for a quick visual review after you work through the notes.

open cheatsheets

Score calculator

Estimate your broader AP score goal after you review the course and exam format.

open calculator

Frequently Asked Questions

What topics are covered in AP CSA Unit 3?

AP CSA Unit 3 covers 9 topics focused on creating your own classes in Java: Abstraction and Program Design, Impact of Program Design, Anatomy of a Class, Constructors, Methods: How to Write Them, Methods: Passing and Returning References of an Object, Class Variables and Methods, Scope and Access, and the `this` Keyword. See AP CSA Unit 3 for matched practice on all of them.

How much of the AP CSA exam is Unit 3?

AP CSA Unit 3 makes up 10-18% of the AP exam, making it one of the more heavily tested units. It covers class creation concepts like constructors, methods, scope and access, class variables, and the `this` keyword. Questions from this unit show up in both the multiple-choice section and the free-response questions.

What's on the AP CSA Unit 3 progress check (MCQ and FRQ)?

The AP CSA Unit 3 progress check includes both MCQ and FRQ parts drawn from the unit's 9 topics. The MCQ portion tests your understanding of constructors, scope and access, class variables, and the `this` keyword. The FRQ portion asks you to write or analyze class definitions, including writing methods and constructors. Head to AP CSA Unit 3 for practice questions that mirror what the progress check covers.

How do I practice AP CSA Unit 3 FRQs?

AP CSA Unit 3 FRQs typically ask you to write a complete class or add methods and constructors to an existing one. The most tested topics are Constructors, Methods: How to Write Them, Methods: Passing and Returning References of an Object, and Scope and Access. To practice, write out full class definitions by hand, check that your constructors initialize all instance variables, and verify your method signatures match the return type. You can find Unit 3 FRQ-style practice at AP CSA Unit 3.

Where can I find AP CSA Unit 3 practice questions?

For AP CSA Unit 3 practice questions, including multiple-choice and practice test problems, go to AP CSA Unit 3. You'll find MCQ-style questions covering Anatomy of a Class, Constructors, Scope and Access, Class Variables and Methods, and the `this` keyword, plus FRQ practice on writing and analyzing class definitions.

How should I study AP CSA Unit 3?

Start AP CSA Unit 3 by making sure you can write a class from scratch: define instance variables, write a constructor that initializes them, and add methods that return or modify those variables. Then work through Scope and Access so you know when to use `private` vs. `public`, and study Class Variables and Methods to understand the difference between instance-level and static members. Practice the `this` keyword in constructors where parameter names shadow instance variable names. After each topic, write a short Java class that uses what you just learned, then check it compiles and runs correctly. AP CSA Unit 3 has practice problems organized by topic to help you spot gaps.

Ready to review Unit 3?Start with the notes, check the topic cards, and use the practice or resource links when they are available for this course.