AP Computer Science A key terms
AP Computer Science A · Get comfortable with the vocabulary.
- Object
- Related: Class, Reference, Instantiation
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.
- Class
- Related: Object, Constructor, Instance Variable
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.
- Instantiation
- Related: Constructor, Object, Reference
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.
- Constructor
- Related: Instantiation, Overloading, Instance Variable
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.
- Reference
- Related: Alias, Null, Object
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.
- Alias
- Related: Reference, Mutator Method, Object
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.
- Null
- Related: Reference, Runtime Error
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.
- Instance Variable
- Related: Encapsulation, Accessor Method, Mutator Method
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.
- Static Variable
- Related: Static Method, Instance 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.
- Static Method
- Related: Static Variable, Class Method Call
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.
- Accessor Method
- Related: Mutator Method, Encapsulation
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.
- Mutator Method
- Related: Accessor Method, Encapsulation, Alias
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.
- Encapsulation
- Related: Instance Variable, Accessor Method, Mutator Method
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.
- Private Access Modifier
- Related: Public Access Modifier, Encapsulation
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.
- Public Access Modifier
- Related: Private Access Modifier, Encapsulation
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.
- This Reference
- Related: Instance Variable, Constructor
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.
- Method Signature
- Related: Overloading, Parameter
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.
- Overloading
- Related: Method Signature, Constructor, Parameter
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.
- Parameter
- Related: Argument, Pass by Value, Method Signature
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.
- Argument
- Related: Parameter, Method Signature
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.
- Pass by Value
- Related: Parameter, Reference, Alias
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.
- Return Statement
- Related: Method Signature, Void Method
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.
- Void Method
- Related: Return Statement, Mutator 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.
- Class Method Call
- Related: Static Method, Object 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.
- Object Method Call
- Related: Reference, This Reference, Null
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.
- Primitive Type
- Related: Wrapper Class, Autoboxing, Reference
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.
- Wrapper Class
- Related: Autoboxing, Primitive Type, ArrayList
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.
- Autoboxing
- Related: Wrapper Class, Primitive Type
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.
- Casting
- Related: Primitive Type, Inheritance, Integer Division
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.
- Integer Division
- Related: Modulus Operator, Casting, Primitive Type
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.
- Modulus Operator
- Related: Integer Division
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.
- Boolean Expression
- Related: If Statement, Short-Circuit Evaluation, While Loop
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.
- Relational Operator
- Related: Equals Method, Boolean Expression, Reference
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.
- Equals Method
- Related: Relational Operator, Object, Alias
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.
- Short-Circuit Evaluation
- Related: Boolean Expression, Null
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.
- If Statement
- Related: Boolean Expression, Nested Conditional, While Loop
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.
- Nested Conditional
- Related: If Statement, Boolean Expression
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.
- While Loop
- Related: For Loop, Boolean Expression, Infinite 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.
- For Loop
- Related: While Loop, Enhanced For Loop, Off-by-One Error
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.
- Enhanced For Loop
- Related: For Loop, Array, ArrayList
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.
- Infinite Loop
- Related: While Loop, For 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.
- Off-by-One Error
- Related: For Loop, Array Index, ArrayIndexOutOfBoundsException
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.
- Array
- Related: Array Index, ArrayIndexOutOfBoundsException, ArrayList
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.
- Array Index
- Related: Array, Off-by-One Error, ArrayIndexOutOfBoundsException
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.
- ArrayIndexOutOfBoundsException
- Related: Array Index, Runtime Error, Array
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.
- ArrayList
- Related: Wrapper Class, Autoboxing, Array
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.
- Traversal
- Related: For Loop, Enhanced For Loop, Array
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.
- Runtime Error
- Related: Null, ArrayIndexOutOfBoundsException, Logic 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.
- Logic Error
- Related: Runtime Error, Off-by-One Error, Traversal
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.