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.
Tap the card or press Space to flip
The 10 sample cards as a list
-
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 -
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 oftenClass Creation › Anatomy of a Class
void.
Example:getBalance()versusdeposit(50). -
What is the difference between
privateandpublicaccess?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 -
Inside a
BankAccountmethod, can code read the privatebalanceof a differentBankAccountobject passed as a parameter?Yes. Access is checked per class, not per object, so any code written insideClass Creation › Anatomy of a ClassBankAccountmay useother.balancedirectly. -
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
-
What does
new int[5]contain right after it is created, compared withnew String[5]?Five 0 values for the int array; fiveData Collections › Arraysnullreferences for the String array. Arrays are filled with the type's default value. -
Given
int[] a = {3, 1, 4, 1, 5};which expression gives the last element?Data Collections › Arraysa[a.length - 1], which is 5. Indices run from 0 tolength - 1.
Watch out:a[a.length]throws anArrayIndexOutOfBoundsException. -
How do you get the size of an array, a String and an ArrayList?Array: the fieldData Collections › Arrays
arr.length(no parentheses). String: the methods.length(). ArrayList: the methodlist.size(). -
Why does
for (int v : arr) v *= 2;leave the array unchanged?In an enhanced for loop,Data Collections › Arraysvis a copy of each element, so changingvchanges only the copy. Use an indexed loop witharr[i] *= 2to modify the array. -
An enhanced for loop runs over an array of
Studentobjects and callss.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.