Skip to main content

AP® Computer Science A Unit 1 flashcardsUsing Objects and Methods

40 cards · about 10 minutes for the whole deck

Flashcard drill

Space flips the card, arrow keys move, and keys 1 to 4 rate how well you knew it.

Position
1 / 40
Due
40
Mastered
0 / 40
Saved on this device · Sign in to sync

This card: New

Something wrong with this card?

What's wrong?

Please don't include personal details.

Flip the card before you rate it.

  • Algorithm

    A step-by-step process for solving a problem. The order of the steps (sequencing) matters, since the same steps in a different order can give a different result.

    Topic 1.1: Introduction to Algorithms, Programming, and Compilers

  • Compiler

    The tool that checks your Java for syntax errors and translates it so it can run. Code with a syntax error won't run at all.

    Topic 1.1: Introduction to Algorithms, Programming, and Compilers

  • Syntax error

    A mistake in the rules of the language, like a missing semicolon or brace. The compiler catches it before the program can run.

    Topic 1.1: Introduction to Algorithms, Programming, and Compilers

  • Logic error

    A mistake that lets the program run but gives the wrong result, like averaging with the wrong formula. Testing with known answers finds it.

    Topic 1.1: Introduction to Algorithms, Programming, and Compilers

  • Run-time error

    An error that happens while the program is running and makes it stop early. An exception, like dividing an int by 0, is one kind.

    Topic 1.1: Introduction to Algorithms, Programming, and Compilers

  • Primitive type

    A basic type that holds a simple value directly. This course uses three: int (whole numbers), double (decimals) and boolean (true/false).

    Topic 1.2: Variables and Data Types

  • Reference type

    Any class type, like String. A reference variable holds a reference (like an address) to an object, not the object itself.

    Topic 1.2: Variables and Data Types

  • Integer division

    Dividing two ints gives an int and drops the decimal part: 7 / 2 is 3. Make one value a double to keep the decimal: 7 / 2.0 is 3.5.

    Topic 1.3: Expressions and Output

  • Remainder operator %

    Gives the remainder after integer division: 17 % 5 is 2. n % 2 == 0 checks for even numbers, and n % 10 gets the last digit.

    Topic 1.3: Expressions and Output

  • Escape sequence

    A backslash code inside a string literal: \" is a double quote, \\ is a backslash and \n is a new line.

    Topic 1.3: Expressions and Output

  • print vs. println

    System.out.print prints and stays on the same line. System.out.println prints and then moves to the next line.

    Topic 1.3: Expressions and Output

  • ArithmeticException

    The exception thrown when you divide an int by the int 0 (with / or %). It happens while the program runs, not at compile time.

    Topic 1.3: Expressions and Output

  • Assignment operator =

    Works out the value on the right first, then stores it in the variable on the left. So x = x + 1 uses the old x to make the new one.

    Topic 1.4: Assignment Statements and Input

  • null

    The value of a reference variable that doesn't point to any object. Calling a method on null throws a NullPointerException.

    Topic 1.4: Assignment Statements and Input

  • Casting

    Converting a value to another type: (int) 3.9 is 3 and (double) 7 is 7.0. A cast applies only to the value right after it.

    Topic 1.5: Casting and Range of Variables

  • Rounding with a cast

    (int) (x + 0.5) rounds a non-negative double x to the nearest int. Casting alone always cuts off the decimal part.

    Topic 1.5: Casting and Range of Variables

  • Integer overflow

    Going past Integer.MAX_VALUE or Integer.MIN_VALUE. Java doesn't stop; the value wraps around to the other end of the range.

    Topic 1.5: Casting and Range of Variables

  • Round-off error

    A tiny error because most decimals can't be stored exactly in a double. 0.1 + 0.2 == 0.3 is false for this reason.

    Topic 1.5: Casting and Range of Variables

  • Compound assignment operator

    A shortcut like +=, -=, *=, /= or %= that does the math with the variable's current value and stores the result back: x += 3 is x = x + 3.

    Topic 1.6: Compound Assignment Operators

  • ++ and --

    count++ adds 1 and count-- subtracts 1. On the exam they're only used as statements on their own, after the variable.

    Topic 1.6: Compound Assignment Operators

  • API documentation

    The description of a library's classes: their constructors and methods, what they need and what they do. You can use a class without seeing its code.

    Topic 1.7: Application Program Interface (API) and Libraries

  • Attribute vs. behavior

    An attribute is data an object stores (like a title). A behavior is something it can do (like play), written as a method.

    Topic 1.7: Application Program Interface (API) and Libraries

  • Precondition

    A condition that must be true before a method is called. The method doesn't check it; the caller is responsible.

    Topic 1.8: Documentation with Comments

  • Postcondition

    A condition that will be true after a method finishes, such as what it returns, as long as its preconditions were met.

    Topic 1.8: Documentation with Comments

  • Method signature

    A method's name plus its parameter types in order, like area(int, int). The return type and parameter names aren't part of it.

    Topic 1.9: Method Signatures

  • Overloading

    Several methods (or constructors) with the same name but different parameter lists. Java picks the one whose parameters match the arguments.

    Topic 1.9: Method Signatures

  • Call by value

    Java passes a copy of each argument's value. Changing a primitive parameter inside a method never changes the caller's variable.

    Topic 1.9: Method Signatures

  • Class method

    A method marked static that belongs to the class, not an object. Call it with the class name: Math.sqrt(16.0).

    Topic 1.10: Calling Class Methods

  • Math.random()

    Returns a double from 0.0 up to but not including 1.0. (int) (Math.random() * n) + a gives a random int from a to a + n - 1.

    Topic 1.11: Math Class

  • Math.pow and Math.sqrt

    Math.pow(a, b) gives aᵇ and Math.sqrt(x) gives √x. Both return a double, so Math.pow(2, 3) is 8.0.

    Topic 1.11: Math Class

  • Object

    One specific instance of a class, with its own copy of the class's data. A class is the blueprint; objects are what you build from it.

    Topic 1.12: Objects: Instances of Classes

  • Superclass and subclass

    A subclass inherits from its superclass. Every class in Java is a subclass of Object.

    Topic 1.12: Objects: Instances of Classes

  • Constructor

    Code that sets up a new object. It has the same name as the class and runs when you use new, like new Book("Emma", 300).

    Topic 1.13: Object Creation and Storage (Instantiation)

  • Aliasing

    Two reference variables that refer to the same object, as after b = a;. A change made through one shows up through the other.

    Topic 1.13: Object Creation and Storage (Instantiation)

  • NullPointerException

    Thrown when you call a method on a reference that holds null, because there's no object to call it on.

    Topic 1.14: Calling Instance Methods

  • Immutable String

    A String can't be changed. Methods like substring return a new string, so you must store the result to keep it.

    Topic 1.15: String Manipulation

  • substring(a, b)

    Returns the characters from index a up to but not including index b, so its length is b - a. substring(a) goes to the end.

    Topic 1.15: String Manipulation

  • indexOf(str)

    Returns the index where str first appears, or -1 if it isn't there.

    Topic 1.15: String Manipulation

  • equals vs. == for strings

    a.equals(b) checks whether two strings have the same characters. == only checks whether they're the same object, so use equals.

    Topic 1.15: String Manipulation

  • compareTo

    a.compareTo(b) is negative if a comes first alphabetically, 0 if they're equal and positive if a comes after b.

    Topic 1.15: String Manipulation