AP Computer Science A study materials
AP Computer Science A study resources

AP Computer Science A key terms

AP Computer Science A · Get comfortable with the vocabulary.

Object

A runtime entity that bundles state (instance variables) with behavior (methods), created from a class using new. Variables of a class type hold a reference to an object rather than the object's data itself.

Related: Class, Reference, Instantiation
Class

A blueprint that declares the instance variables and methods shared by all objects created from it. It defines type and behavior but allocates no object storage until an instance is constructed.

Related: Object, Constructor, Instance Variable
Instantiation

The act of creating a new object from a class, typically with the new keyword followed by a constructor call. The result is a reference to freshly allocated, initialized object storage.

Related: Constructor, Object, Reference
Constructor

A special method with the same name as its class and no return type, invoked when an object is created. It initializes instance variables and may be overloaded with different parameter lists.

Related: Instantiation, Overloading, Instance Variable
Reference

A value that identifies where an object lives in memory rather than holding the object's contents. Assigning or passing a reference copies the pointer, so two variables can share one object.

Related: Alias, Null, Object
Alias

A situation where two or more reference variables point to the same object, so a mutation made through one is visible through the others. Aliasing is a frequent source of unexpected side effects.

Related: Reference, Mutator Method, Object
Null

A special reference value meaning "points to no object." Calling a method or accessing a field through a null reference throws a NullPointerException at run time.

Related: Reference, Runtime Error
Instance Variable

A field declared in a class whose storage exists separately in each object. It holds the object's state and is usually declared private so it can be changed only through the class's methods.

Related: Encapsulation, Accessor Method, Mutator Method
Static Variable

A field declared with the static keyword that belongs to the class itself, not to any single object. All instances share one copy, and it is accessed through the class name.

Related: Static Method, Instance Variable
Static Method

A method declared with static that is invoked through the class name and has no implicit object. It cannot directly use instance variables or the this reference.

Related: Static Variable, Class Method Call
Accessor Method

A method, conventionally named getSomething, that returns information about an object's state without changing it. Accessors support encapsulation by exposing values while hiding storage details.

Related: Mutator Method, Encapsulation
Mutator Method

A method, conventionally named setSomething, that modifies an object's instance variables. Mutators let a class control and validate changes to its state instead of exposing fields directly.

Related: Accessor Method, Encapsulation, Alias
Encapsulation

The practice of hiding an object's data behind private fields and public methods. It protects invariants and lets the class change its internal representation without breaking client code.

Related: Instance Variable, Accessor Method, Mutator Method
Private Access Modifier

A visibility keyword restricting a field or method so it can be used only within its own class. Client code in other classes cannot read or call it directly.

Related: Public Access Modifier, Encapsulation
Public Access Modifier

A visibility keyword allowing a class, method, or field to be used from any other class. Methods that form a class's interface to clients are typically declared public.

Related: Private Access Modifier, Encapsulation
This Reference

The implicit reference inside an instance method that names the object on which the method was invoked. It distinguishes instance variables from parameters that share the same name.

Related: Instance Variable, Constructor
Method Signature

The combination of a method's name and the number, types, and order of its parameters. The return type and parameter names are not part of the signature used to choose among overloads.

Related: Overloading, Parameter
Overloading

Declaring several methods with the same name but different parameter lists in one class. The compiler selects the version to call based on the argument types at the call site.

Related: Method Signature, Constructor, Parameter
Parameter

A variable declared in a method's header that receives a copy of each argument supplied by the caller. For primitive types the copy is the value; for objects it is a copy of the reference.

Related: Argument, Pass by Value, Method Signature
Argument

An actual value or expression supplied at a method call, matched positionally to the method's parameters. Its compile-time type must be assignable to the corresponding parameter type.

Related: Parameter, Method Signature
Pass by Value

Java's argument-passing rule: the method receives a copy of the argument. Reassigning a parameter never affects the caller, though mutating a shared object through a copied reference is visible.

Related: Parameter, Reference, Alias
Return Statement

A statement that ends execution of a method and hands a value back to the caller. Its expression type must be assignable to the method's declared return type, or void methods use bare return.

Related: Method Signature, Void Method
Void Method

A method declared to return nothing, so it cannot be used where a value is expected. It is typically called for its side effects, such as printing or updating state.

Related: Return Statement, Mutator Method
Class Method Call

Invoking a static method using the class name, as in Math.abs(-3), without any object. Contrasted with instance method calls, which require a reference to a specific object.

Related: Static Method, Object Method Call
Object Method Call

Invoking an instance method through a reference, as in str.length(), so the method runs with that object as its implicit this. A null reference here causes a runtime exception.

Related: Reference, This Reference, Null
Primitive Type

One of Java's eight basic non-object types, such as int, double, and boolean, which store a value directly. They have no methods and are compared with == by value.

Related: Wrapper Class, Autoboxing, Reference
Wrapper Class

A class such as Integer or Double that packages a primitive value inside an object. Wrappers provide utility methods and allow primitives to be stored in collections.

Related: Autoboxing, Primitive Type, ArrayList
Autoboxing

The automatic conversion the compiler performs between a primitive and its matching wrapper class, such as int to Integer. Unboxing is the reverse conversion, applied when a primitive is required.

Related: Wrapper Class, Primitive Type
Casting

An explicit conversion that tells the compiler to treat a value as another type. Casting a double to int truncates toward zero, and casting a superclass reference to a subclass requires the object's actual type to match.

Related: Primitive Type, Inheritance, Integer Division
Integer Division

Division of two int values, which discards the fractional part and yields an int. For example, 7 / 2 evaluates to 3, and the result is truncated toward zero, not rounded.

Related: Modulus Operator, Casting, Primitive Type
Modulus Operator

The % operator, which yields the remainder after integer division, as in 7 % 2 giving 1. Its sign follows the dividend, and it is often used to test divisibility or extract digits.

Related: Integer Division
Boolean Expression

An expression whose value is true or false, built from comparisons, logical operators, and boolean variables. It supplies the condition that controls selection and iteration statements.

Related: If Statement, Short-Circuit Evaluation, While Loop
Relational Operator

A comparison operator such as <, <=, >, or >= that produces a boolean. For object references, == and != compare references rather than contents, so equals is used for value equality.

Related: Equals Method, Boolean Expression, Reference
Equals Method

An instance method that reports whether two objects should be considered equal in value. Classes override it so content comparison works, since == on references only tests identity.

Related: Relational Operator, Object, Alias
Short-Circuit Evaluation

The rule that && stops evaluating once the left operand is false and || stops once it is true. It lets a test guard the right operand, such as checking for null before a method call.

Related: Boolean Expression, Null
If Statement

A control structure that executes a block only when its boolean condition is true, optionally with else and else-if branches. Exactly one branch of a connected chain runs.

Related: Boolean Expression, Nested Conditional, While Loop
Nested Conditional

An if or if-else statement placed inside a branch of another conditional. Correct indentation and braces matter because a dangling else binds to the nearest unmatched if.

Related: If Statement, Boolean Expression
While Loop

A loop that repeats its body as long as its condition remains true, testing before each iteration. If the condition is false initially the body never runs, and a non-changing condition causes an infinite loop.

Related: For Loop, Boolean Expression, Infinite Loop
For Loop

A counted loop with initialization, a continuation condition, and an update, all in one header. It suits a known number of iterations and its loop variable is scoped to the loop.

Related: While Loop, Enhanced For Loop, Off-by-One Error
Enhanced For Loop

A for-each loop that visits each element of an array or collection in order without an index. It cannot be used to remove elements or to modify the underlying structure safely.

Related: For Loop, Array, ArrayList
Infinite Loop

A loop whose condition never becomes false, so it never terminates. Common causes are forgetting to update the loop variable or updating it in the wrong direction.

Related: While Loop, For Loop
Off-by-One Error

A logic mistake where a loop or index is one position too far or too short, such as using <= with length. It often causes skipped elements or an out-of-bounds exception.

Related: For Loop, Array Index, ArrayIndexOutOfBoundsException
Array

A fixed-size, indexed collection of values of one type, created with new and given a length that cannot change. Elements are accessed by index from 0 through length - 1.

Related: Array Index, ArrayIndexOutOfBoundsException, ArrayList
Array Index

An integer position identifying an element of an array, valid from 0 to one less than the array's length. The last valid index is length - 1, and length is a field, not a method.

Related: Array, Off-by-One Error, ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsException

A runtime exception thrown when an array is accessed with an index below 0 or at least its length. It is not caught by the compiler and terminates the program unless handled.

Related: Array Index, Runtime Error, Array
ArrayList

A resizable, indexed list class from java.util that grows and shrinks as elements are added or removed. It stores object references, so primitives must be wrapped before insertion.

Related: Wrapper Class, Autoboxing, Array
Traversal

Visiting every element of an array or collection in sequence, usually with a loop, to read, count, or process values. Standard patterns include finding a maximum, summing, and counting matches.

Related: For Loop, Enhanced For Loop, Array
Runtime Error

An error that occurs while a program is executing, such as a null access, a bad index, or division by zero. It halts execution with an exception rather than being caught at compile time.

Related: Null, ArrayIndexOutOfBoundsException, Logic Error
Logic Error

A flaw in a program's reasoning that lets it compile and run but produce incorrect results. It is found by testing and tracing rather than by the compiler.

Related: Runtime Error, Off-by-One Error, Traversal