Skip to main content

Unit 3

10–18% of exam

Class Creation

In Unit 3 you stop just using classes and start writing your own. You plan a class from a written description, then write its private instance variables, its constructors and its methods, and you learn how static, scope and the this keyword work. You also think about the real-world impact of the programs people write. It sets you up for the Class Design free-response question.

Study this unit

Flashcards (34)Practice questions (52)Computer Science A must-know sheet

Free-response questions on this unit

Write your own answer, then score it with the rubric or with AI.

Big ideas

  • Abstraction hides details so you can focus on what a class or method does
  • Encapsulation keeps instance variables private and exposes behavior through methods
  • A constructor sets an object's initial state
  • Object parameters pass a copy of the reference, so methods can change the original object
  • Programs affect people, so programmers have legal and ethical responsibilities

Full unit reviews

Longer videos that cover the whole unit. Good for a first pass or a final review.

  • AP Computer Science A Unit 3 Review | Class Creation (AP CSA Exam Prep)

    Goldie's Math EmporiumWatch on YouTube (opens in a new tab)

  • 2026 AP Computer Science A Exam Review - CRASH COURSE for Unit 3: Class Creation

    Tim Gallagher Computer ScienceWatch on YouTube (opens in a new tab)

  • AP CSA Unit 3 Full Review | NEW 2026 |

    Scratch SkillsWatch on YouTube (opens in a new tab)

  • AP Computer Science A - Unit 5: Writing Classes

    Bill BarnumWatch on YouTube (opens in a new tab)

Abstraction means hiding details so you can focus on the main idea. Data abstraction names data (like a class's attributes) without showing how it's stored, and procedural abstraction lets you use a method knowing only what it does. Breaking a big behavior into smaller methods, and planning classes with diagrams, makes programs easier to build and reuse.

Key terms

  • abstraction
  • data abstraction
  • procedural abstraction
  • method decomposition
  • instance variable
  • class variable
Read the review notes: 3.1 Abstraction and Program Design

A few quick questions on this topic, with the answers explained.

A reliable program does what it should under the stated conditions, which is why you test it with many kinds of input. Programs can help or harm society, the economy and culture, sometimes in ways nobody intended, and reusing someone else's code raises legal questions: open-source code is free to use under its license, but other code needs permission.

Key terms

  • system reliability
  • unintended consequences
  • intellectual property
  • open source
  • licensing
Read the review notes: 3.2 Impact of Program Design

A few quick questions on this topic, with the answers explained.

Every class you write starts with a header like public class Name, followed by a body with its instance variables, constructors and methods. Encapsulation means hiding a class's inner details: instance variables are private, so only the class itself can use them, while public methods and constructors give other classes controlled access. Each object gets its own copy of the instance variables.

Key terms

  • encapsulation
  • private
  • public
  • instance variable
  • class header
  • AP CSA - Unit 5: Writing Classes – Lesson 1: Anatomy of a Class

    Goldie's Math EmporiumWatch on YouTube (opens in a new tab)

  • AP CS A 5.1- Anatomy of Classes

    CodeHSWatch on YouTube (opens in a new tab)

  • Java encapsulation 💊

    Bro CodeWatch on YouTube (opens in a new tab)

  • Encapsulation in Java Tutorial #83

    Alex LeeWatch on YouTube (opens in a new tab)

  • Introduction to Abstraction, Ethics, and Data Encapsulation [APCSA 3.1 - 3.3]

    LearnAPCSAWatch on YouTube (opens in a new tab)

  • 2026 AP Computer Science A Exam Review - Exploring FRQ 2: Class Design

    Tim Gallagher Computer ScienceWatch on YouTube (opens in a new tab)

Read the review notes: 3.3 Anatomy of a Class

A few quick questions on this topic, with the answers explained.

An object's state is the current values of its instance variables (the object has-a name, has-a score, and so on). A constructor sets that starting state, usually from its parameters, and if a parameter is a mutable object, the safe move is to store a copy, not the caller's reference. If you write no constructor, Java supplies a no-parameter default one, and the instance variables start at 0, 0.0, false or null.

Key terms

  • constructor
  • state
  • has-a relationship
  • default constructor
  • default values
Read the review notes: 3.4 Constructors

A few quick questions on this topic, with the answers explained.

A void method does a job and returns nothing, while a non-void method returns one value of its declared type. Accessor methods (getters) hand back a copy of an instance variable's value, and mutator methods (setters) change it. A return statement exits the method right away, and changing a primitive parameter never changes the caller's variable.

Key terms

  • void method
  • return type
  • return statement
  • accessor method
  • mutator method
  • AP Computer Science A - Topic 3.5 - Part 1: Writing Mutator Methods

    Tim Gallagher Computer ScienceWatch on YouTube (opens in a new tab)

  • Methods: How to Write Them

    CodeHSWatch on YouTube (opens in a new tab)

  • AP CSA Class Creation – Accessor and Mutator Methods

    Goldie's Math EmporiumWatch on YouTube (opens in a new tab)

  • AP Computer Science A - Topic 3.5 - Part 2: Writing Accessor Methods

    Tim Gallagher Computer ScienceWatch on YouTube (opens in a new tab)

  • Getters & Setters (Java Tutorial)

    Bill BarnumWatch on YouTube (opens in a new tab)

  • AP Computer Science A - Topic 3.5 - Part 3: Writing methods with Pre- and Post- Conditions

    Tim Gallagher Computer ScienceWatch on YouTube (opens in a new tab)

Read the review notes: 3.5 Methods: How to Write Them

A few quick questions on this topic, with the answers explained.

When you pass an object to a method, the parameter gets a copy of the reference, not a copy of the object, so the method can change the original object's state. Returning an object also returns a reference. A method can use the private data of a parameter only when that parameter's type is the method's own class.

Key terms

  • object reference
  • pass by value
  • mutable object
  • returning a reference
Read the review notes: 3.6 Methods: Passing and Returning References of an Object

A few quick questions on this topic, with the answers explained.

A static (class) variable is shared by every object of the class, unlike an instance variable, where each object has its own copy. Static methods can work with static variables and call other static methods, but there's no object behind them, so they can't use instance variables or instance methods unless an object is passed in. A variable marked final can't be changed once it has a value.

Key terms

  • class variable
  • class method
  • static
  • final
  • shared copy
  • AP Computer Science A - Topic 3.7 - Part 1: Class Variables

    Tim Gallagher Computer ScienceWatch on YouTube (opens in a new tab)

  • Class Variables and Methods

    CodeHSWatch on YouTube (opens in a new tab)

  • Static vs Non-Static Variables and Methods In Java - Full Simple Tutorial

    Coding with JohnWatch on YouTube (opens in a new tab)

  • AP Computer Science A - Topic 3.7 - Part 2: Writing Class Methods

    Tim Gallagher Computer ScienceWatch on YouTube (opens in a new tab)

  • Java Fields (Class Variables & Instance Variables)*

    Bill BarnumWatch on YouTube (opens in a new tab)

  • Java final keyword ⛔

    Bro CodeWatch on YouTube (opens in a new tab)

Read the review notes: 3.7 Class Variables and Methods

A few quick questions on this topic, with the answers explained.

A local variable, including a parameter, exists only inside the block where it's declared and can't be marked public or private. When a parameter or local variable has the same name as an instance variable, that name means the local one inside the method or constructor; this is called shadowing.

Key terms

  • scope
  • local variable
  • block
  • shadowing
Read the review notes: 3.8 Scope and Access

A few quick questions on this topic, with the answers explained.

Inside a constructor or instance method, this refers to the current object, the one the method was called on. You often see this.name = name to set an instance variable when a parameter has the same name, and you can pass this as an argument. Static methods have no this.

Key terms

  • this
  • current object
  • instance variable vs. parameter
Read the review notes: 3.9 this Keyword

A few quick questions on this topic, with the answers explained.