AP Computer Science A Vocabulary

0.0(0)
Studied by 0 people
0%Unit Mastery
0%Exam Mastery
Build your Mastery score
multiple choiceMultiple Choice
call kaiCall Kai
Supplemental Materials
Card Sorting

1/325

flashcard set

Earn XP

Description and Tags

Last updated 4:22 PM on 3/4/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

326 Terms

1
New cards

2D array

An array of arrays in Java used to represent tabular data with rows and columns; each element is accessed using two indices: arr[row][col].



Example: "To represent a seating chart for a classroom with 5 rows and 6 columns, a programmer might declare int[][] seats = new int[5][6]; and access the seat in the third row, second column as seats[2][1]."

2
New cards

2D array dimensions

For a 2D array arr, arr.length gives the number of rows, and arr[0].length gives the number of columns in each row.



Example: "When writing a method to print a multiplication table stored as a 2D array table, the outer loop condition uses table.length for the number of rows, and the inner loop condition uses table[0].length for the number of columns."

3
New cards

@param tag

A Javadoc tag used in method documentation to describe a parameter; the format is @param paramName description.



Example: "In the Javadoc comment above a calculateArea method, the developer writes @param radius the radius of the circle in centimeters to document the meaning of the parameter before the method signature."

4
New cards

@return tag

A Javadoc tag used in method documentation to describe the return value of a non-void method.



Example: "Above the method public double getAverage(int[] scores), the Javadoc comment includes @return the arithmetic mean of all values in the scores array to describe what the method sends back to the caller."

5
New cards

Absolute value

The magnitude of a number without its sign; always non-negative. In Java, computed using Math.abs().



Example: "To compute the distance between two points on a number line, the programmer writes int distance = Math.abs(pointA - pointB);, which ensures the result is always non-negative regardless of the order of subtraction."

6
New cards

Abstract class

A class declared with the abstract keyword that cannot be instantiated; it may contain abstract methods without a body that must be implemented by concrete subclasses.



Example: "The class Shape is declared abstract because every shape has an area, but the formula differs per shape, so Shape defines public abstract double getArea(); and leaves it to Circle and Rectangle to provide concrete implementations."

7
New cards

Abstract method

A method declared with the abstract keyword in an abstract class that has no implementation; subclasses must provide a concrete implementation.



Example: "In the abstract class Animal, the method public abstract String makeSound(); forces every concrete subclass such as Dog and Cat to supply its own implementation, ensuring that calling makeSound() on any Animal reference always produces a meaningful result."

8
New cards

Abstraction

The process of focusing on essential characteristics while hiding unnecessary details; in OOP, abstraction is achieved through classes and interfaces.



Example: "When designing a BankAccount class, the programmer uses          by exposing only deposit(), withdraw(), and getBalance() methods to callers, hiding the internal bookkeeping of how the balance is maintained."

9
New cards

Access modifier

A keyword that specifies the visibility of a class, method, or variable; the main access modifiers in Java are public, private, and protected.



Example: "Declaring an instance variable private int balance; inside a BankAccount class ensures that code outside the class cannot directly read or modify the balance, enforcing data integrity."

10
New cards

Accessor method

A public method that returns the value of a private instance variable without modifying it; also called a getter method.



Example: "The method public String getName() { return name; } is an          that allows other classes to read the private name field of a Student object without exposing the field directly."

11
New cards

Accumulator

A variable used in a loop to collect or aggregate values as the loop iterates; commonly used to compute sums, products, or counts.



Example: "In a loop that sums all elements of an int[] array, the variable int total = 0; declared before the loop serves as the         , growing with each iteration via total += arr[i];."

12
New cards

Accumulator pattern

A common programming pattern where a variable is initialized before a loop and then updated on each iteration to collect a running total, maximum, minimum, or concatenated result.



Example: "To find the highest score in an array, the          initializes int max = scores[0]; before the loop, then updates max = Math.max(max, scores[i]); on each iteration to track the running maximum."

13
New cards

Actual parameter

The value or expression passed to a method when it is called; also called an argument.



Example: "In the call Math.pow(2, 10), the values 2 and 10 are the          passed to the pow method, which maps them onto the formal parameters base and exponent."

14
New cards

Actual parameter list

The arguments specified in a particular method call.



Example: "When calling printStudentInfo("Alice", 95, true), the          consists of the string "Alice", the integer 95, and the boolean true, in that order, matching the method's formal parameter types."

15
New cards

Algorithm

A step-by-step process or set of rules to be followed in calculations or problem-solving operations, especially by a computer.



Example: "Selection sort is an          that repeatedly finds the minimum element from the unsorted portion of an array and swaps it into its correct position, eventually producing a fully sorted array."

16
New cards

Algorithm efficiency

A measure of the computational resources required by an algorithm; typically expressed as time complexity using Big O notation.



Example: "When choosing between linear search and binary search for a sorted array of one million elements,          is critical: linear search is O(n) and may examine all million elements, while binary search is O(log n) and needs at most about 20 comparisons."

17
New cards

Aliasing

A situation where two reference variables point to the same object; modifying the object through one reference affects what is seen through the other.



Example: "After executing int[] b = a;, both a and b refer to the same array object, so calling b[0] = 99; also changes what is seen through a[0]—a classic          situation that can cause subtle bugs."

18
New cards

API

Application Programming Interface; a specification of how a programmer interacts with a library's classes and methods, typically documented using Javadoc.



Example: "The Java String          specifies that substring(int beginIndex, int endIndex) returns a new string from beginIndex up to but not including endIndex, so developers know how to use the method without reading its source code."

19
New cards

API documentation

Formal documentation of a class's public interface describing the purpose, parameters, and return values of each method; typically generated using Javadoc.



Example: "Before using the ArrayList class, a student consults the          to discover that remove(int index) shifts all subsequent elements left, which explains why removing elements inside a forward-iterating index loop requires special care."

20
New cards

Argument

The actual value passed to a method when it is called; the argument is assigned to the corresponding parameter in the method definition.



Example: "In the method call circle.setRadius(5.0), the double literal 5.0 is the          whose value is copied into the formal parameter radius inside the setRadius method."

21
New cards

Arithmetic expression

A combination of numeric literals, variables, and arithmetic operators that evaluates to a numeric value.



Example: "The          (length * width) / 2 combines the variables length and width with multiplication and division operators to compute the area of a triangle."

22
New cards

Array

A data structure that stores a fixed-size, ordered collection of elements of the same type; each element is accessed using an integer index starting at 0.



Example: "Declaring int[] grades = new int[30]; creates an          that holds exactly 30 integer values, each initialized to 0, with indices ranging from 0 to 29."

23
New cards

Array algorithm

A standard procedure applied to array data, such as finding the minimum or maximum value, computing a sum, or counting elements that match a condition.



Example: "A standard          to count how many elements exceed a threshold traverses the array with a for loop, increments a counter whenever arr[i] > threshold, and returns the counter after the loop."

24
New cards

Array element

An individual value stored at a specific position in an array; accessed using bracket notation with its index (e.g., arr[2]).



Example: "After declaring String[] days = {"Mon", "Tue", "Wed", "Thu", "Fri"};, the          days[2] holds the value "Wed", the third element in the array."

25
New cards

Array initialization

Setting up an array in memory either with default values (new int[5]) or with specific values using an initializer list ({1, 2, 3, 4, 5}).



Example: "The declaration double[] prices = {1.99, 3.49, 0.75}; uses an initializer list to immediately populate the array with three specific values, eliminating the need for separate assignment statements."

26
New cards

Array length

The number of elements in an array, accessed via the .length property; for an array arr, arr.length gives the total number of elements.



Example: "A method that reverses an array constructs the mirrored index with arr.length - 1 - i, relying on the length property to avoid hardcoding the array size and make the method work for any array."

27
New cards

Array of objects

An array whose elements are object references rather than primitive values; each element can be null or refer to an object of the declared type.



Example: "Declaring Student[] roster = new Student[25]; creates an array of 25 Student references, all initially null; each element must be assigned a new Student(...) object before it can be used."

28
New cards

Array vs ArrayList

Arrays have fixed size and use bracket syntax for access; ArrayLists are resizable and use method calls (get(), add(), remove()); arrays can hold primitives, ArrayLists cannot directly.



Example: "When the number of student records is fixed at 30, an int[] array is appropriate; but when students can be added or dropped throughout the semester, an ArrayList<Student> is preferable because it resizes automatically."

29
New cards

ArrayIndexOutOfBoundsException

A runtime exception thrown when a program attempts to access an array element using an index that is negative or greater than or equal to the array's length.



Example: "Using arr[arr.length] instead of arr[arr.length - 1] to access the last element will throw an <u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</u> at runtime because valid indices only go up to arr.length - 1."

30
New cards

ArrayList

A resizable array implementation in Java from the java.util package that can grow and shrink dynamically; stores objects (not primitives) and provides methods like add(), remove(), get(), and size().



Example: "To maintain a list of students that can grow as new students enroll, a programmer declares <u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</u><String> students = new <u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</u><>(); and uses students.add("Maria") to append each new name."

31
New cards

ArrayList of objects

An ArrayList parameterized with a class type that stores references to objects of that type; requires autoboxing for primitive values.



Example: "An ArrayList<Rectangle> stores Rectangle objects by reference, so when a Rectangle's setWidth() method is called through the list, the change is reflected in the actual object stored in the list."

32
New cards

ArrayList.add()

A method that appends an element to the end of an ArrayList, or inserts an element at a specified index shifting subsequent elements right.



Example: "Calling list.add(0, "first") inserts the string "first" at index 0 of the ArrayList, shifting every existing element one position to the right and increasing the list's size by one."

33
New cards

ArrayList.get()

A method that returns the element at a specified index in an ArrayList without removing it.



Example: "To print the middle element of an ArrayList<Integer> named nums, a programmer writes System.out.println(nums.get(nums.size() / 2));, using get() to retrieve the element at the computed index."

34
New cards

ArrayList.remove()

A method that removes an element from an ArrayList either by index or by object value; subsequent elements shift left to fill the gap.



Example: "When traversing an ArrayList with an index-based loop and calling list.remove(i), the programmer must decrement i afterward because all subsequent elements shift left, or the next element will be skipped."

35
New cards

ArrayList.set()

A method that replaces the element at a specified index in an ArrayList with a new value and returns the old element.



Example: "To replace the highest score in an ArrayList<Integer> at position maxIndex with a corrected value, the programmer calls scores.set(maxIndex, correctedScore), which returns the old value and stores the new one."

36
New cards

ArrayList.size()

A method that returns the number of elements currently stored in an ArrayList; unlike arrays, this changes as elements are added or removed.



Example: "The condition i < list.size() in a while loop ensures the loop terminates correctly even if elements are removed during iteration, because size() reflects the current number of elements after each removal."

37
New cards

Assignment statement

A statement that stores a value into a variable using the assignment operator (=), evaluating the right side and storing the result in the variable on the left.



Example: "The statement total = total + currentValue; is an assignment that evaluates the right-hand expression and stores the updated sum back into the variable total."

38
New cards

Autoboxing

Java's automatic conversion of a primitive type to its corresponding wrapper class object when needed; for example, an int is automatically converted to an Integer when added to an ArrayList.



Example: "When a programmer writes ArrayList<Integer> list = new ArrayList<>(); and then calls list.add(42);, Java automatically autoboxes the primitive int value 42 into an Integer object before adding it to the list."

39
New cards

Base case

The condition in a recursive method that stops further recursive calls and returns a result directly without making another recursive call; prevents infinite recursion.



Example: "In a recursive method that computes the factorial of n, the          if (n == 0) return 1; terminates the chain of recursive calls so the method does not recurse infinitely."

40
New cards

Big O notation

A mathematical notation used to describe the worst-case time complexity of an algorithm as a function of input size n; common complexities are O(1), O(log n), O(n), O(n log n), and O(n squared).



Example: "Bubble sort compares adjacent pairs and repeats for every element, performing roughly n squared comparisons in the worst case, so its time complexity is described as O(n squared) in         ."

41
New cards

Binary search

A search algorithm that works on sorted arrays by repeatedly dividing the search interval in half; much more efficient than linear search with O(log n) time complexity but requires sorted data.



Example: "Because          requires sorted data, a programmer first sorts the array with a sorting algorithm, then applies          to locate a target value in O(log n) time rather than examining every element as linear search would."

42
New cards

Block

A sequence of statements enclosed in curly braces { } that is treated as a single unit; used in method bodies, if statements, and loops.



Example: "The body of an if statement enclosed in curly braces { int temp = a; a = b; b = temp; } forms a          that swaps two variables, and the variable temp is local to that         ."

43
New cards

Boolean

A primitive data type in Java that stores only two values: true or false.



Example: "The variable <u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</u> isPassing = (score >= 60); stores true if the student's score is at least 60 and false otherwise, making it easy to use in conditional logic later."

44
New cards

Boolean algebra

The mathematical rules governing operations on boolean values (true and false), including AND, OR, NOT, and equivalence laws like De Morgan's laws.



Example: "Applying De Morgan's law from         , a programmer simplifies !(isRaining && isCold) to !isRaining || !isCold, making the condition easier to read and reason about."

45
New cards

Boolean condition

A condition that evaluates to true or false, used to control the flow of if statements and loops.



Example: "The          count > 0 && sum / count > threshold in an if statement guards against division by zero while also checking whether the average exceeds the threshold."

46
New cards

Boolean expression

An expression that evaluates to either true or false; used as conditions in if statements, loops, and other control structures.



Example: "The          (x >= 0) && (x < arr.length) evaluates to true only when x is a valid index for the array, and is commonly used to validate indices before accessing array elements."

47
New cards

Boolean flag

A boolean variable used to track whether a condition has been met or an event has occurred during a loop or algorithm.



Example: "A programmer uses a          boolean found = false; before a search loop, sets it to true inside the loop when a match is discovered, and checks the flag after the loop to decide what to print."

48
New cards

Boundary condition

A special case at the edge of an algorithm's domain, such as an empty array, a single-element array, or the first or last index; these often require special handling.



Example: "When testing a binary search implementation, a programmer must verify          such as searching for a value in a single-element array, searching for the first element, and searching for the last element."

49
New cards

Bytecode

Platform-independent code generated by the Java compiler that can be executed by the Java Virtual Machine (JVM) on any operating system.



Example: "After the Java compiler translates HelloWorld.java into HelloWorld.class, the resulting          can be executed by the JVM on Windows, macOS, or Linux without recompilation, demonstrating Java's platform independence."

50
New cards

Call stack

A data structure that tracks active method calls in a program; each recursive call adds a new stack frame, and the stack unwinds as each call returns.



Example: "When fibonacci(4) calls fibonacci(3), which calls fibonacci(2), each invocation is pushed onto the          as a new frame; once the base cases return, the stack unwinds and each pending call receives its result."

51
New cards

CamelCase

A naming convention in Java where compound words are written with each word capitalized except the first; used for variable and method names (e.g., myVariableName).



Example: "Following Java's          convention, a method that calculates compound interest is named calculateCompoundInterest() rather than calculatecompoundinterest() or calculate_compound_interest()."

52
New cards

Casting

Explicit conversion from one data type to another.



Example: "To perform true division instead of integer division, the programmer writes double average = (double) totalScore / numStudents;,          totalScore to a double before the division so the decimal portion is retained."

53
New cards

Catch

A Java programming language keyword used to declare a block of statements to be executed in the event that a Java exception, or run time error, occurs in a preceding "try" block.



Example: "In a try-         block, the <u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</u> (ArrayIndexOutOfBoundsException e) clause handles the case where user input provides an invalid array index, preventing the program from crashing and printing a helpful error message instead."

54
New cards

Chained method calls

Calling multiple methods in sequence by using the return value of one method call as the object on which to call the next method; for example, str.substring(1).toUpperCase().



Example: "The expression sentence.trim().toLowerCase().replace(" ", "_") uses          to first remove leading and trailing spaces, then convert to lowercase, and finally replace spaces with underscores, all in one readable line."

55
New cards

Character processing

Operations that work with individual characters in a string, often obtained using charAt() and then tested or modified.



Example: "To count the number of vowels in a string, a method iterates through each character using str.charAt(i) and checks whether it equals 'a', 'e', 'i', 'o', or 'u', incrementing a counter on each match."

56
New cards

Class

A blueprint or template that defines the attributes (instance variables) and behaviors (methods) shared by all objects of that type.



Example: "The Dog          defines instance variables name and breed along with methods bark() and fetch(), serving as a blueprint from which individual Dog objects like myDog and neighborsDog are created."

57
New cards

Class body

The content of a class enclosed in curly braces, containing the class's instance variables, constructors, and method definitions.



Example: "The          of Circle contains the private instance variable double radius, a constructor that sets radius, and public methods getArea() and getCircumference(), all enclosed within the outer curly braces."

58
New cards

Class definition

The code that specifies the structure of a class, including its instance variables, constructors, and methods; serves as the blueprint for creating objects.



Example: "The          for Rectangle specifies two private double fields length and width, a constructor to initialize them, and methods getArea() and getPerimeter() that compute and return the corresponding values."

59
New cards

Class header

The first line of a class definition that specifies the class's access modifier, name, and optionally what it extends or implements.



Example: "The          public class GradedActivity extends Activity implements Comparable<GradedActivity> tells the compiler that GradedActivity is a public class that inherits from Activity and implements the Comparable interface."

60
New cards

Class instantiation

The process of creating a new object from a class definition using the new keyword and a constructor call.



Example: "The statement Student s = new Student("Jordan", 11); performs         , calling the two-parameter constructor of Student to create a new object and storing a reference to it in the variable s."

61
New cards

Class method

A method that is invoked without reference to a particular object. Class methods affect the class as a whole, not a particular instance of the class. Also called a static method.



Example: "Math.sqrt(25.0) is called as a          (static method) directly on the Math class without creating a Math object, returning the double value 5.0."

62
New cards

Class specification

A description of what a class does and how it should behave, including its public methods and their contracts, independent of implementation details.



Example: "Before coding, a team writes a          for ShoppingCart that describes the public methods addItem(), removeItem(), getTotal(), and their expected behaviors, without dictating how the internal list of items will be stored."

63
New cards

Class variable

A variable declared with the static keyword that belongs to the class itself rather than to any instance; shared by all objects of the class.



Example: "Declaring private static int instanceCount = 0; inside a class and incrementing it in every constructor creates a          that tracks how many objects of that class have been created across the entire program."

64
New cards

Code block

A sequence of Java statements enclosed in curly braces { }; defines the scope of variables declared within it.



Example: "A variable declared inside the          of a for loop, such as int temp = arr[i];, is only accessible within that block and is destroyed when the loop iteration ends."

65
New cards

Code reuse

The practice of using existing classes and methods to solve new problems without rewriting code; supported by inheritance, APIs, and method decomposition.



Example: "By having SavingsAccount extend BankAccount, the programmer achieves          because SavingsAccount inherits deposit() and getBalance() without rewriting them, and only adds the addInterest() behavior that is unique to savings accounts."

66
New cards

Code tracing

The process of manually following the execution of a program step by step to determine what values variables hold and what output is produced.



Example: "By          through the loop for (int i = 1; i <= 4; i++) { sum += i; }, a student tracks that sum takes on the values 0, 1, 3, 6, and finally 10, confirming the loop computes the sum of 1 through 4."

67
New cards

Column

A vertical set of elements in a 2D array; the second index in a 2D array access (arr[row][col]) identifies the column.



Example: "Trajan's          in Rome, completed in 113 CE, transforms the standard architectural          into a public monument, its shaft wound with a continuous spiral relief of over 2,500 carved figures narrating the emperor's two Dacian campaigns with remarkable documentary specificity."

68
New cards

Column-major order

A traversal pattern for 2D arrays where all rows of one column are processed before moving to the next column; the outer loop iterates over columns, inner loop over rows.



Example: "To print a 2D array column by column, the programmer uses          with the outer loop iterating col from 0 to arr[0].length - 1 and the inner loop iterating row from 0 to arr.length - 1, printing arr[row][col] each time."

69
New cards

Comment

Explanatory text in source code that is ignored by the compiler; Java supports single-line comments (//) and multi-line block comments (/* ... */).



Example: "A single-line          written as // swap arr[i] and arr[j] above a three-line swap sequence helps a reader understand the intent of the code without reading every detail of the implementation."

70
New cards

Comparison operator

An operator that compares two values and returns a boolean; includes ==, !=,



Example: "The expression score >= 90 uses the          >= to return true when score is 90 or above, which an if statement can then use to assign the letter grade 'A'."

71
New cards

Compiler

A program that translates source code written in a programming language (like Java) into bytecode or machine code that can be executed by a computer.



Example: "When a Java source file contains a method call with the wrong number of arguments, the          reports a compile-time error before any bytecode is generated, preventing the flawed program from running."

72
New cards

Compound assignment operator

A shorthand operator that combines an arithmetic operation with assignment; examples include +=, -=, *=, /=, and %=.



Example: "Inside a loop that processes test scores, the statement total += scores[i]; uses the          += as a concise alternative to writing total = total + scores[i];."

73
New cards

Compound expression

An expression that combines multiple operators and operands; operator precedence rules determine the order of evaluation.



Example: "The          a + b * c - d / e is evaluated according to Java's operator precedence rules: multiplication and division are performed before addition and subtraction, so b * c and d / e are computed first."

74
New cards

Concatenation operator

The + operator when used with strings in Java to join them together; when a non-string is added to a string, it is automatically converted to a string.



Example: "The statement String message = "Score: " + score + "/" + total; uses the          + to build a single string from a mix of string literals and integer variables, automatically converting each int to its string representation."

75
New cards

Concurrent modification

An error that occurs when an ArrayList is modified while being traversed with an enhanced for loop; use an index-based loop when adding or removing elements during traversal.



Example: "Attempting to call list.remove(element) inside an enhanced for loop over that list causes a ConcurrentModificationException; the correct approach is to use an index-based loop and decrement the index after each removal."

76
New cards

Conditional expression

A boolean expression used as the condition in an if statement or loop to determine which code path to follow.



Example: "In the loop while (left <= right), the          left <= right controls how long the binary search continues, becoming false and stopping the loop when the search space is exhausted."

77
New cards

Conditional statement

A statement that executes different code depending on whether a boolean condition is true or false; includes if, if-else, and if-else-if chains.



Example: "An if-else-if          assigns letter grades by checking if (score >= 90) for A, else if (score >= 80) for B, and so on, so only the first true branch executes."

78
New cards

Constructor

A special method with the same name as the class that is called when creating a new object using the new keyword; it initializes the object's instance variables.



Example: "The          public Rectangle(double length, double width) { this.length = length; this.width = width; } initializes a new Rectangle object's instance variables whenever new Rectangle(5.0, 3.0) is called."

79
New cards

Constructor chaining

The process of one constructor calling another constructor in the same class using this(), or calling a superclass constructor using super().



Example: "A ColoredCircle class uses          by calling super(radius) as the first statement in its constructor, delegating the initialization of the radius field to the parent Circle class constructor."

80
New cards

Constructor signature

The class name plus the ordered list of parameter types that uniquely identifies a constructor; used to distinguish overloaded constructors.



Example: "A class provides two constructors with different signatures—Point(int x, int y) and Point(double x, double y)—allowing callers to construct a Point using either integer or double coordinates."

81
New cards

Content equality

Comparing the actual data stored in two objects using the equals() method, rather than checking if they are the same object in memory.



Example: "Comparing two String objects with str1.equals(str2) tests          and returns true when both strings contain the same sequence of characters, unlike == which only checks if they are the same object in memory."

82
New cards

Data abstraction

Hiding the implementation details of how data is stored and managed, exposing only the operations that can be performed on the data.



Example: "A Stack class achieves          by exposing only push(), pop(), and peek() methods, hiding whether the underlying storage uses an array or a linked list so that callers are unaffected if the implementation changes."

83
New cards

Data structure

A way of organizing and storing data in a computer so that it can be accessed and modified efficiently; examples in AP CS A include arrays and ArrayLists.



Example: "An ArrayList<String> is the appropriate          for a to-do list application because it allows dynamic insertion and deletion at any position, unlike a fixed-size array."

84
New cards

Data type

A classification that specifies what kind of value a variable can hold and what operations can be performed on it; examples include int, double, boolean, and String.



Example: "Choosing the          double instead of int for a variable storing a student's GPA ensures that the fractional portion, such as the 0.75 in 3.75, is not truncated."

85
New cards

De Morgan's laws

Boolean algebra rules for negating compound expressions: !(A && B) is equivalent to !A || !B, and !(A || B) is equivalent to !A && !B.



Example: "When a programmer wants to skip processing an element unless it is both positive and even, they can rewrite the condition !(num > 0 && num % 2 == 0) using          as num <= 0 || num % 2 != 0, which is often easier to reason about."

86
New cards

Declaration

A statement that introduces a variable to the compiler, specifying its name and data type (e.g., int score;).



Example: "The          int count; tells the compiler to reserve a memory location for an integer variable named count, but it does not yet assign a value, so the variable must be initialized before use."

87
New cards

Decrement operator

The -- operator that subtracts 1 from a variable's value; for example, x-- is equivalent to x = x - 1.



Example: "In a countdown loop, i-- in the update expression of for (int i = 10; i >= 1; i--) decreases i by 1 after each iteration, causing the loop to print 10 through 1."

88
New cards

Default constructor

A constructor with no parameters that initializes instance variables to default values; Java provides one automatically if no constructors are defined.



Example: "If a programmer defines no constructors in the Point class, Java supplies a          that creates a Point with x and y both initialized to 0, their default values for the int type."

89
New cards

Default value

The value automatically assigned to instance variables when an object is created without explicit initialization; numeric types default to 0, boolean to false, and reference types to null.



Example: "After creating a new int[5] array without explicit initialization, each element holds the          0, so iterating over the array immediately after creation will print five zeros."

90
New cards

Definition

A declaration that reserves storage (for data) or provides implementation (for methods).



Example: "The method          public int square(int n) { return n * n; } both declares the method signature and provides its implementation, while a mere declaration would only state the signature without a body."

91
New cards

Divide-and-conquer

An algorithm design strategy that breaks a problem into smaller subproblems, solves each subproblem recursively, and combines the results; used by merge sort and binary search.



Example: "Merge sort applies the          strategy by recursively splitting the array in half until each subarray has one element, then merging the sorted halves back together, resulting in an O(n log n) overall sort."

92
New cards

Dot operator

The . symbol used to access members (methods or fields) of an object or class.



Example: "The expression student.getName() uses the          to invoke the getName() method on the student object, accessing its behavior through the object reference."

93
New cards

Double

A primitive data type in Java that stores 64-bit double-precision floating-point numbers, used for decimal values.



Example: "Storing a temperature reading in <u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</u> temperature = 98.6; uses the <u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</u> type to preserve the decimal precision that an int would lose by truncating to 98."

94
New cards

Dynamic binding

The process by which Java determines at runtime which version of an overridden method to call, based on the actual type of the object rather than the reference type.



Example: "When an Animal reference variable holds a Cat object and makeSound() is called, Java uses          to invoke Cat's overridden version of makeSound() at runtime rather than Animal's version."

95
New cards

Early return

A return statement that exits a method before reaching the end of the method body when a certain condition is met; useful for simplifying logic.



Example: "A method searching for a target in an array uses an         : if (arr[i] == target) return i; inside the loop, immediately exiting with the found index rather than continuing to scan the rest of the array."

96
New cards

Element-based traversal

Iterating through an array using an enhanced for loop that accesses each element directly rather than by index; useful for reading but cannot modify element references.



Example: "Using for (int score : scores) to sum all grades in an array is an          that reads each value directly without an index, but it cannot be used to reassign array elements since score is a copy of each value."

97
New cards

Encapsulation

An object-oriented design principle where the internal state of an object is hidden from outside access by declaring variables private and providing public accessor and mutator methods.



Example: "By declaring private double balance; and providing only public void deposit(double amount) and public double getBalance(), the BankAccount class uses          to prevent external code from setting the balance to an invalid negative value."

98
New cards

Enhanced for loop

A simplified for loop syntax used to iterate over all elements of an array or ArrayList without needing an index variable; syntax: for (Type element : collection).



Example: "The          for (String name : nameList) iterates over every element in the ArrayList<String> named nameList, assigning each string to name in turn without requiring the programmer to manage an index variable."

99
New cards

Equals() method

A method inherited from the Object class used to test whether two objects are logically equal; should be overridden to compare object contents rather than references.



Example: "Two Student objects with the same id field should be considered equal, so the Student class overrides equals() to return true when this.id == other.id rather than when they are the same object in memory."

100
New cards

Escape sequence

A combination of characters starting with a backslash that represents a special character in a string; examples include \n for newline, \t for tab, and \" for double quote.



Example: "The statement System.out.println("Name:\tAlice\nGrade:\t95"); uses the          \t for a tab character and \n for a newline to format the output into two neatly aligned lines."

Explore top notes

note
1984 - Introduction Notes
Updated 1723d ago
0.0(0)
note
geologic absolute age notes
Updated 1760d ago
0.0(0)
note
123
Updated 841d ago
0.0(0)
note
Hello
Updated 1187d ago
0.0(0)
note
Chapter 1 - The Earth (copy)
Updated 1432d ago
0.0(0)
note
Factorisation (copy)
Updated 1073d ago
0.0(0)
note
KOREAN - IMPORTANT VOCABULARY
Updated 1254d ago
0.0(0)
note
1984 - Introduction Notes
Updated 1723d ago
0.0(0)
note
geologic absolute age notes
Updated 1760d ago
0.0(0)
note
123
Updated 841d ago
0.0(0)
note
Hello
Updated 1187d ago
0.0(0)
note
Chapter 1 - The Earth (copy)
Updated 1432d ago
0.0(0)
note
Factorisation (copy)
Updated 1073d ago
0.0(0)
note
KOREAN - IMPORTANT VOCABULARY
Updated 1254d ago
0.0(0)

Explore top flashcards

flashcards
faf
40
Updated 957d ago
0.0(0)
flashcards
faf
40
Updated 957d ago
0.0(0)