Sign Up Free

AP Computer Science A: Key Terms

Flashcards 30 questions Test Preparation > AP Computer Science A by Katie Valentine
Study this material interactively with flashcards, quizzes, and games on GabaBrain.
Study on GabaBrain

Flashcards (30)

Card 1
Primitive Data Type
Answer
A basic data type, such as int, double, or boolean, that stores its value directly in memory and does not refer to an object. Unlike reference types, primitives hold the actual data, not a memory address.
Understanding the distinction between primitives and reference types is fundamental for memory management and object-oriented programming.
Card 2
Reference Data Type
Answer
A data type that stores a memory address (a reference) to an object, rather than the object's value itself. All objects in Java are reference types, including arrays and String.
When you assign one object variable to another, you are copying the reference, not the entire object.
Card 3
Object
Answer
An instance of a class, representing a specific entity with its own state (instance variables) and behavior (methods). Objects are created using the 'new' keyword and a constructor.
A class is a blueprint, and an object is a house built from that blueprint.
Card 4
Class
Answer
A blueprint or template that defines the structure and behavior for objects of a certain type. It specifies the instance variables and methods that its objects will possess.
Think of a class as the cookie cutter and objects as the individual cookies.
Card 5
Constructor
Answer
A special method within a class that is automatically called when an object is instantiated using the 'new' keyword. Its purpose is to initialize the new object's instance variables.
Constructors ensure objects start in a valid and predictable state.
Card 6
Instance Variable
Answer
A variable declared within a class but outside any method, representing a piece of data unique to each object (instance) of that class. Each object has its own copy of instance variables.
These variables define the state of an individual object.
Card 7
Static Variable (Class Variable)
Answer
A variable declared with the 'static' keyword within a class, which belongs to the class itself rather than to any specific object. All objects of the class share a single copy of a static variable.
Use static variables for data that is common to all instances or describes the class as a whole, like a counter for objects created.
Card 8
Method Overloading
Answer
Defining multiple methods within the same class that have the same name but different parameter lists (different number, type, or order of parameters). This allows a single method name to perform similar operations on different types or numbers of inputs.
Overloading is a compile-time polymorphism feature, allowing flexibility in method calls without changing the method's core purpose.
Card 9
Method Overriding
Answer
Redefining a method in a subclass that was already defined in its superclass, using the exact same method signature (name, return type, and parameter list). This allows the subclass to provide its own specific implementation for an inherited method.
Overriding is a runtime polymorphism feature, enabling specialized behavior in subclasses while maintaining a common method interface.
Card 10
Inheritance
Answer
A mechanism in object-oriented programming where a new class (subclass) derives properties and behaviors (instance variables and methods) from an existing class (superclass). This promotes code reuse and establishes an "is-a" relationship between classes.
Inheritance allows you to build upon existing code, creating a hierarchy of related classes.
Card 11
Polymorphism
Answer
The ability of an object to take on many forms, allowing a single reference variable to refer to objects of different types that share a common superclass or interface. This enables methods to be called on objects without knowing their exact runtime type.
Polymorphism makes code more flexible and extensible by allowing generic code to work with specific, varying object types.
Card 12
Abstract Class
Answer
A class declared with the 'abstract' keyword that cannot be instantiated directly, but can be subclassed. It may contain abstract methods (methods without an implementation) which its concrete subclasses must implement.
Abstract classes serve as a template for subclasses, enforcing that certain methods are implemented by them.
Card 13
Interface
Answer
A contract that defines a set of abstract methods that a class must implement if it declares itself to implement that interface. Interfaces specify "what" a class must do without specifying "how" it does it.
Interfaces support multiple inheritance of type, providing common behavior specifications across unrelated classes.
Card 14
Array
Answer
A fixed-size, ordered collection of elements of the same data type, stored in contiguous memory locations and accessed by an integer index starting from zero. Once created, its size cannot be changed.
Arrays are efficient for storing and accessing a known, fixed number of elements of the same type.
Card 15
ArrayList
Answer
A resizable array implementation from the Java Collections Framework that stores objects. Unlike a traditional array, an ArrayList can dynamically grow or shrink in size as elements are added or removed.
ArrayLists are highly flexible when the number of elements is unknown or changes frequently.
Card 16
Recursion
Answer
A programming technique where a method calls itself, directly or indirectly, to solve a problem by breaking it down into smaller, similar subproblems. A recursive method must have a base case to stop the recursion.
Recursion often provides elegant solutions for problems that can be naturally divided into smaller, self-similar instances, like traversing trees or calculating factorials.
Card 17
Base Case (Recursion)
Answer
The condition within a recursive method that specifies when the recursion should stop and a direct solution can be returned, preventing infinite recursion. Without a base case, a recursive method will cause a stack overflow error.
The base case is the "escape clause" that prevents a recursive method from running forever.
Card 18
Stack Overflow Error
Answer
An error that occurs when a program, typically a recursive method without a proper base case, makes too many nested method calls, exceeding the available memory on the call stack. This results in the program terminating.
This error indicates that the program is trying to store too much information about active method calls than the system can handle.
Card 19
NullPointerException
Answer
A runtime error that occurs when a program attempts to use a reference variable that currently points to no object (i.e., it holds the value 'null') as if it were referring to an actual object. This often happens when trying to call a method or access a field on a null reference.
Always check if an object reference is null before attempting to use it, especially when dealing with user input or external data.
Card 20
Encapsulation
Answer
The principle of bundling data (instance variables) and the methods that operate on that data within a single unit (a class), and restricting direct access to some of an object's components. This is typically achieved using access modifiers like 'private'.
Encapsulation protects an object's internal state from external, unauthorized modification, promoting data integrity.
Card 21
'this' keyword
Answer
A reference variable that refers to the current object itself within an instance method or constructor. It is commonly used to distinguish between instance variables and method parameters that have the same name, or to call another constructor from within a constructor.
Using 'this.variableName = variableName;' in a constructor clarifies which variable is the instance variable and which is the parameter.
Card 22
'super' keyword
Answer
A reference variable used within a subclass to refer to the immediate superclass's members, such as calling a superclass's constructor or accessing a superclass's overridden method or instance variable.
'super()' must be the first statement in a subclass constructor if you explicitly call a superclass constructor.
Card 23
Wrapper Class
Answer
A class in Java (e.g., Integer, Double, Boolean) that encapsulates a primitive data type value within an object. These classes provide methods for working with primitive values as objects, enabling them to be stored in collections like ArrayLists.
Wrapper classes bridge the gap between Java's primitive types and its object-oriented nature, allowing primitives to be treated as objects.
Card 24
Autoboxing
Answer
The automatic conversion that the Java compiler performs between a primitive type and its corresponding wrapper class object. For example, an 'int' can be automatically converted to an 'Integer' object.
Autoboxing simplifies code by removing the need for explicit conversion between primitives and their wrapper objects.
Card 25
Unboxing
Answer
The automatic conversion that the Java compiler performs from a wrapper class object to its corresponding primitive type. For example, an 'Integer' object can be automatically converted to an 'int' value.
Unboxing allows wrapper objects to be used in contexts where primitive values are expected, such as arithmetic operations.
Card 26
Enhanced For Loop (For-Each Loop)
Answer
A simplified loop construct designed for iterating over elements in arrays and other iterable collections without explicitly managing an index. It processes each element in the collection in sequence.
This loop makes code more readable and less prone to off-by-one errors when simply iterating through all elements.
Card 27
Logical Operators (&&, ||, !)
Answer
Operators used to combine or modify boolean expressions: '&&' (logical AND) returns true if both operands are true; '||' (logical OR) returns true if at least one operand is true; '!' (logical NOT) inverts a boolean value.
These operators are crucial for constructing complex conditional statements in control flow.
Card 28
Scope
Answer
The region of a program where a variable or method can be accessed. Variables declared inside a method or loop have local scope, while instance variables have class scope.
Understanding scope helps prevent naming conflicts and ensures variables are used only where they are intended.
Card 29
Static Method (Class Method)
Answer
A method declared with the 'static' keyword that belongs to the class itself, rather than to any specific object. Static methods can be called directly on the class name and cannot access instance variables or non-static methods directly.
Use static methods for utility functions that don't depend on the state of a particular object, like 'Math.random()'.
Card 30
Access Modifier
Answer
Keywords in Java (e.g., public, private, protected) that set the visibility and accessibility of classes, methods, and variables. They control which parts of the code can access a member.
Access modifiers are fundamental to encapsulation, dictating how components of a class can interact with the outside world.

Ready to study AP Computer Science A: Key Terms?

Study with flashcards, play quiz games, challenge your friends, and track your progress.

Start Studying Free