A step-by-step procedure for solving a problem or accomplishing a task
Program
A set of instructions written in a programming language that a computer can execute
Source Code
Human-readable instructions written in a programming language (like Java)
Bytecode
Intermediate code generated by the Java compiler; executed by the JVM
Compiler
Software that translates source code into bytecode (javac for Java)
Java Virtual Machine (JVM)
The runtime environment that executes Java bytecode
Syntax
The rules that define how code must be written in a programming language
Syntax Error
An error caused by violating the rules of the programming language
Logic Error
An error where code runs but produces incorrect results
Runtime Error
An error that occurs while the program is executing
Comment
Text in code that is ignored by the compiler; used for documentation
Variables and Data Types
Term
Definition
Variable
A named storage location in memory that holds a value
Data Type
The classification of data that determines what values it can hold
Primitive Type
A basic data type built into Java (int, double, boolean, char)
int
A primitive type that stores whole numbers (32-bit integers)
double
A primitive type that stores decimal numbers (64-bit floating-point)
boolean
A primitive type that stores true or false
Declaration
The statement that creates a variable with a specific type
Initialization
Assigning an initial value to a variable
Literal
A fixed value written directly in code (e.g., 42, 3.14, "Hello")
Constant
A variable whose value cannot change after initialization (uses final)
Expressions and Operators
Term
Definition
Expression
A combination of values, variables, and operators that evaluates to a single value
Operator
A symbol that performs an operation on one or more operands
Arithmetic Operator
Operators that perform mathematical calculations (+, -, *, /, %)
Modulo (%)
The remainder operator; returns the remainder after division
Integer Division
Division between integers that discards any decimal portion
Operator Precedence
The order in which operators are evaluated in an expression
Compound Assignment
Combines an operation with assignment (+=, -=, *=, /=)
Increment (++)
Increases a variable's value by 1
Decrement (--)
Decreases a variable's value by 1
Casting
Explicitly converting a value from one data type to another
Concatenation
Joining two strings together using the + operator
Objects and Classes
Term
Definition
Object
An instance of a class that contains data and behavior
Class
A blueprint or template that defines the structure and behavior of objects
Instance
A specific object created from a class
Instantiation
The process of creating an object using the new keyword
Constructor
A special method that initializes a new object
Reference
A variable that stores the memory address of an object
null
A special value indicating that a reference points to nothing
NullPointerException
An error that occurs when calling a method on a null reference
Methods
Term
Definition
Method
A named block of code that performs a specific task
Method Call
Executing a method by using its name followed by parentheses
Method Signature
The combination of a method's name and parameter types
Parameter
A variable in a method definition that receives a value when called
Argument
The actual value passed to a method when it is called
Return Type
The data type of the value a method sends back
void
A return type indicating a method returns no value
Static Method
A method that belongs to the class rather than an instance
Dot Operator (.)
Used to access methods and variables of an object
The String Class
Term
Definition
String
An object that represents a sequence of characters
Immutable
Cannot be changed after creation (Strings are immutable)
length()
Returns the number of characters in a String
substring()
Returns a portion of a String
indexOf()
Returns the position of a character or substring within a String
equals()
Compares two Strings for identical content
compareTo()
Compares two Strings lexicographically
Zero-indexed
A counting system where the first position is 0
The Math Class
Term
Definition
Math.abs()
Returns the absolute value of a number
Math.pow()
Returns a number raised to a power
Math.sqrt()
Returns the square root of a number
Math.random()
Returns a random double from 0.0 (inclusive) to 1.0 (exclusive)
Math.min()
Returns the smaller of two values
Math.max()
Returns the larger of two values
Unit 2: Selection and Iteration
22.5-27.5% of AP Exam • Decision-Making & Repetition
Boolean Logic
Term
Definition
Boolean Expression
An expression that evaluates to true or false
Relational Operator
Compares two values (<, >, <=, >=, ==, !=)
Equality (==)
Tests if two primitive values are equal
Inequality (!=)
Tests if two values are not equal
AND (&&)
Returns true only if both operands are true
OR (||)
Returns true if at least one operand is true
NOT (!)
Reverses a boolean value
Short-circuit Evaluation
Stopping evaluation when the result is already determined
De Morgan's Laws
Rules for negating compound boolean expressions
Conditional Statements
Term
Definition
Conditional Statement
A statement that executes code based on a condition
if Statement
Executes code only if a condition is true
if-else Statement
Executes one block if true, another if false
else if
Tests an additional condition when previous conditions are false
Nested Conditional
An if statement inside another if statement
Block
Code enclosed in curly braces { }
Scope
The region of code where a variable can be accessed
Iteration (Loops)
Term
Definition
Iteration
Repeating a set of instructions multiple times
Loop
A control structure that repeats code
Loop Body
The block of code that executes each iteration
Loop Control Variable
A variable that controls how many times a loop runs
while Loop
Repeats while a condition is true; checks before each iteration
for Loop
A loop with initialization, condition, and update in one line
for-each Loop
Iterates through each element in an array or collection
Infinite Loop
A loop that never terminates
Off-by-one Error
A loop that runs one too many or one too few times
Counter Variable
A variable that counts iterations
Accumulator
A variable that accumulates a running total
Nested Loop
A loop inside another loop
break
Immediately exits the innermost loop
String Traversal & Algorithms
Term
Definition
String Traversal
Processing each character in a String one at a time
charAt()
Returns the character at a specified index
Linear Search
Checking each element in order until finding a match
Counting Algorithm
Counts how many elements meet a condition
Sum Algorithm
Calculates the total of a collection of values
🔓 Unlock the Complete Vocabulary List
Enter your email to instantly access Units 3 & 4, Common Exam Traps, and the Alphabetical Index
Unit 3: Class Creation
Unit 4: Data Collections
Exam Trap Quick Reference
Downloadable PDF
📧 We'll also send you weekly AP CSA tips. Unsubscribe anytime.
Unit 3: Class Creation
20-25% of AP Exam • Writing Your Own Classes
Class Structure
Term
Definition
Class Definition
The code that describes a class's variables and methods
Instance Variable
A variable that belongs to each instance of a class
Field
Another term for instance variable
State
The current values of an object's instance variables
Behavior
The actions an object can perform (defined by methods)
Client Code
Code that uses a class (outside the class definition)
Encapsulation and Access
Term
Definition
Encapsulation
Bundling data and methods together; hiding implementation details
Information Hiding
Restricting direct access to internal data
Access Modifier
Keywords that control visibility (public, private)
public
Accessible from any class
private
Accessible only within the same class
Accessor Method (Getter)
A method that returns the value of an instance variable
Mutator Method (Setter)
A method that changes the value of an instance variable
Constructors
Term
Definition
Constructor
A special method that initializes a new object
Default Constructor
A no-argument constructor (provided by Java if none written)
Constructor Overloading
Having multiple constructors with different parameter lists
this
A reference to the current object
this()
Calls another constructor in the same class
Methods in Detail
Term
Definition
Method Decomposition
Breaking a complex problem into smaller methods
Helper Method
A private method that assists other methods
Overloading
Multiple methods with the same name but different parameters
Formal Parameter
The parameter variable in a method definition
Actual Parameter
The argument passed when calling a method
Pass by Value
Java passes a copy of primitive values to methods
Static Members
Term
Definition
static
Belongs to the class rather than any instance
Static Variable
A variable shared by all instances of a class
Static Method
A method called on the class, not an object
Object Comparison
Term
Definition
== (for objects)
Compares references (memory addresses), not content
equals() method
Compares the content of two objects
Aliasing
When multiple references point to the same object
Unit 4: Data Collections
32.5-40% of AP Exam • Arrays, ArrayLists, 2D Arrays
Arrays
Term
Definition
Array
A fixed-size data structure that holds multiple values of the same type
Element
A single value stored in an array
Index
The position of an element in an array (starts at 0)
Array Initializer List
Creating and populating an array in one step (e.g., {1, 2, 3})
length (property)
Returns the number of elements in an array
Array Traversal
Processing each element in an array
ArrayIndexOutOfBoundsException
Error from accessing an invalid array index
Default Values
Initial values in arrays (0 for numbers, false for boolean, null for objects)
Array Algorithms
Term
Definition
Linear Search
Searching by checking each element from start to end
Selection Sort
Sorting by repeatedly finding the minimum and moving it
Insertion Sort
Sorting by inserting each element into its correct position
Binary Search
Efficient search on sorted arrays by repeatedly halving
Swap
Exchanging two elements' positions
ArrayList
Term
Definition
ArrayList
A resizable array implementation from java.util
Generic Type
The type parameter in angle brackets (e.g., )
add()
Adds an element to the ArrayList
get()
Returns the element at a specified index
set()
Replaces the element at a specified index
remove()
Removes an element at a specified index or by value
size()
Returns the number of elements in the ArrayList
Wrapper Class
Classes that wrap primitives (Integer, Double, Boolean)
Autoboxing
Automatic conversion from primitive to wrapper object
Unboxing
Automatic conversion from wrapper object to primitive
2D Arrays
Term
Definition
2D Array
An array of arrays; represents rows and columns
Row
The first dimension of a 2D array
Column
The second dimension of a 2D array
Row-major Order
Processing a 2D array row by row
Column-major Order
Processing a 2D array column by column
grid[row][col]
The correct syntax to access elements (NOT grid[col][row])
grid.length
Returns the number of rows
grid[0].length
Returns the number of columns (assuming rectangular)
Advanced Topics
Term
Definition
Recursion
A method that calls itself
Base Case
The condition that stops recursion
Recursive Case
The condition where the method calls itself
O(n)
Linear time – runtime grows proportionally with input
O(n²)
Quadratic time – runtime grows with square of input
O(log n)
Logarithmic time – runtime grows slowly (binary search)
⚠️ Common Exam Traps
🔴 String Comparison
// WRONG - compares references
if (str1 == str2)
// CORRECT - compares content
if (str1.equals(str2))
Always use .equals() to compare String content. The == operator checks if two references point to the same object in memory.
🔴 Integer Division
int result = 5 / 2; // Returns 2, not 2.5
double result = 5.0 / 2; // Returns 2.5
double result = (double) 5 / 2; // Returns 2.5
When dividing two integers, Java truncates the decimal. Cast to double before dividing if you need the decimal portion.
🔴 ArrayList Removal in Loops
// WRONG - skips elements after removal
for (int i = 0; i < list.size(); i++) {
if (condition) list.remove(i);
}
// CORRECT - traverse backward
for (int i = list.size() - 1; i >= 0; i--) {
if (condition) list.remove(i);
}
When removing from an ArrayList in a loop, traverse backward to avoid skipping elements.
🔴 2D Array Access Order
// CORRECT: grid[row][col]
int value = grid[2][3]; // Row 2, Column 3
// WRONG: grid[col][row]
int value = grid[3][2]; // This is Row 3, Column 2!
Always remember: row first, then column. Think "RC" like "remote control."
🔴 Enhanced For Loop Limitations
// WRONG - doesn't modify the actual array
for (int num : nums) {
num = num * 2; // Only changes local copy!
}
// CORRECT - use standard for loop to modify
for (int i = 0; i < nums.length; i++) {
nums[i] = nums[i] * 2;
}
Enhanced for loops cannot modify array elements, access the index, or traverse in reverse.
🔴 Off-by-One Errors
// WRONG - ArrayIndexOutOfBoundsException
for (int i = 0; i <= arr.length; i++)
// CORRECT - stops at length - 1
for (int i = 0; i < arr.length; i++)
Arrays are zero-indexed, so valid indices are 0 to length - 1. Use < not <=.
📖 Alphabetical Index
Accessor MethodUnit 3
AccumulatorUnit 2
AlgorithmUnit 1
AliasingUnit 3
AND (&&)Unit 2
ArgumentUnit 1
ArrayUnit 4
ArrayListUnit 4
AutoboxingUnit 4
Base CaseUnit 4
Binary SearchUnit 4
BlockUnit 2
booleanUnit 1
Boolean ExpressionUnit 2
breakUnit 2
BytecodeUnit 1
CastingUnit 1
charAt()Unit 2
ClassUnit 1
CompilerUnit 1
ConcatenationUnit 1
Conditional StatementUnit 2
ConstructorUnit 1, 3
Counter VariableUnit 2
De Morgan's LawsUnit 2
Default ConstructorUnit 3
Dot OperatorUnit 1
doubleUnit 1
ElementUnit 4
EncapsulationUnit 3
equals()Unit 1, 3
ExpressionUnit 1
for LoopUnit 2
for-each LoopUnit 2
Generic TypeUnit 4
Helper MethodUnit 3
ImmutableUnit 1
IndexUnit 1, 4
indexOf()Unit 1
Infinite LoopUnit 2
InstanceUnit 1
Instance VariableUnit 3
InstantiationUnit 1
intUnit 1
Integer DivisionUnit 1
IterationUnit 2
length()Unit 1
length (property)Unit 4
Linear SearchUnit 2, 4
LiteralUnit 1
Logic ErrorUnit 1
LoopUnit 2
Math.random()Unit 1
MethodUnit 1
Method DecompositionUnit 3
Modulo (%)Unit 1
Mutator MethodUnit 3
Nested ConditionalUnit 2
Nested LoopUnit 2, 4
NOT (!)Unit 2
nullUnit 1
NullPointerExceptionUnit 1
ObjectUnit 1
Off-by-one ErrorUnit 2
OperatorUnit 1
OR (||)Unit 2
OverloadingUnit 3
ParameterUnit 1
Pass by ValueUnit 3
Primitive TypeUnit 1
privateUnit 3
publicUnit 3
RecursionUnit 4
ReferenceUnit 1
Relational OperatorUnit 2
Return TypeUnit 1
Row-major OrderUnit 4
Runtime ErrorUnit 1
ScopeUnit 2
Short-circuit EvaluationUnit 2
size()Unit 4
Source CodeUnit 1
StateUnit 3
staticUnit 3
Static MethodUnit 1, 3
StringUnit 1
String TraversalUnit 2
substring()Unit 1
SyntaxUnit 1
Syntax ErrorUnit 1
thisUnit 3
2D ArrayUnit 4
UnboxingUnit 4
VariableUnit 1
voidUnit 1
while LoopUnit 2
Wrapper ClassUnit 4
Zero-indexedUnit 1
Ready to Practice?
Put your vocabulary knowledge to the test with daily practice questions and full-length practice exams.