High school & admissions

AP Computer Science A — Classes, Arrays and Algorithms flashcards

10 of 69 cards free to study here · 2 topics · the whole deck is built into Willys

Units 3–4 of the revised AP Computer Science A course: writing classes, arrays, ArrayList, 2D arrays, searching, sorting and recursion. Inheritance and polymorphism are left out because the revised course dropped that unit.

Learn deck · part of AP Computer Science A · written against: College Board AP Computer Science A Course and Exam Description (Java subset; 2025 revision). Updated 2026-10-10.

Study the free sample

10 cards from the deck as they are. Flip, rate yourself, filter by topic; your progress stays in this browser.

The 10 sample cards as a list
  1. Why are instance variables normally declared private?
    For encapsulation: outside code can reach the data only through the class's methods, so the class controls how its state is read and changed and can keep it valid.
    Class Creation › Anatomy of a Class
  2. What is the difference between an accessor and a mutator method?
    An accessor (getter) returns information about an object without changing it; a mutator (setter) changes the object's state and is often void.

    Example: getBalance() versus deposit(50).
    Class Creation › Anatomy of a Class
  3. What is the difference between private and public access?
    A private member can be used only by code inside its own class; a public member can be used from any class. In AP style, classes, constructors and most methods are public, while instance variables are private.
    Class Creation › Anatomy of a Class
  4. Inside a BankAccount method, can code read the private balance of a different BankAccount object passed as a parameter?
    Yes. Access is checked per class, not per object, so any code written inside BankAccount may use other.balance directly.
    Class Creation › Anatomy of a Class
  5. What are a method's precondition and postcondition?
    A precondition is what must be true before the method is called, which the method is not required to check; a postcondition is what the method guarantees will be true when it finishes.
    Class Creation › Anatomy of a Class
  6. What does new int[5] contain right after it is created, compared with new String[5]?
    Five 0 values for the int array; five null references for the String array. Arrays are filled with the type's default value.
    Data Collections › Arrays
  7. Given int[] a = {3, 1, 4, 1, 5}; which expression gives the last element?
    a[a.length - 1], which is 5. Indices run from 0 to length - 1.

    Watch out: a[a.length] throws an ArrayIndexOutOfBoundsException.
    Data Collections › Arrays
  8. How do you get the size of an array, a String and an ArrayList?
    Array: the field arr.length (no parentheses). String: the method s.length(). ArrayList: the method list.size().
    Data Collections › Arrays
  9. Why does for (int v : arr) v *= 2; leave the array unchanged?
    In an enhanced for loop, v is a copy of each element, so changing v changes only the copy. Use an indexed loop with arr[i] *= 2 to modify the array.
    Data Collections › Arrays
  10. An enhanced for loop runs over an array of Student objects and calls s.setGrade(12) on each. Are the objects changed?
    Yes. The loop variable holds a copy of each reference, so calling a mutator through it changes the actual objects. Only assigning the loop variable a new object would have no effect.
    Data Collections › Arrays

Unlock the whole deck

You are studying a free 10-card sample. All 69 cards of AP Computer Science A — Classes, Arrays and Algorithms, the other 2 AP Computer Science A decks, and spaced-repetition scheduling are built into Willys. 14-day free trial, then $14.99 a year.

In Willys, tap Exam Library at the top of your Decks (or Browse Exam Library… under the + button), find the exam on its shelf or by search, tick it and tap Add.

More AP Computer Science A decks

← All AP Computer Science A decks, with the study guide and topic outline.

About these cards

Review status: Second-reader reviewed, with corrections applied.

Checked against:

  • Topic outline follows the College Board AP Computer Science A Course and Exam Description (revised course, first exam May 2026), Units 3–4 (the AP name is used nominatively; no course or exam text reproduced).
  • Every code trace was checked by compiling and running the equivalent Java (OpenJDK); behavior checked against the Java SE API documentation (reference only, no text copied).
  • Java is a trademark of Oracle and/or its affiliates.

These are independent study notes written for Willys. They are not official exam material, may contain mistakes, and are no substitute for your course, your teacher or the exam owner's own publications. Found an error? Tell us — corrections ship as a new version of the deck.

AP® is a trademark registered by the College Board, which is not affiliated with, and does not endorse, this product.

Use of these pages is covered by our Terms of Use.