AP Computer Science A — Using Objects and Methods (Deep Study Notes)

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

1/49

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

No analytics yet

Send a link to your students to track their progress

50 Terms

1
New cards

Object

A bundle of data (state) and behavior (methods) that you interact with in Java.

2
New cards

State

The data an object “remembers” (e.g., the characters stored in a String, or a Scanner’s current reading position).

3
New cards

Method

A function that belongs to a class/object and can be called to perform an action or compute a value (e.g., length(), nextInt()).

4
New cards

Class

A definition/blueprint that specifies what state and methods its objects have; used as the type for object variables.

5
New cards

Object-oriented programming (OOP)

A programming approach where most work is done by creating objects and calling methods on them.

6
New cards

Java API (Application Programming Interface)

The collection of prewritten Java library classes and methods you are expected to use (e.g., String, Math, wrapper classes).

7
New cards

Instance method

A method called on an object reference (e.g., str.length()); typically uses that object’s state.

8
New cards

Static method

A method called on a class name rather than an object (e.g., Math.sqrt(9)); no instance is needed.

9
New cards

Method signature

A method’s name plus its parameter types (often considered along with its return type); used to determine which method call is valid.

10
New cards

Reference type

A type that refers to an object (class types like String); variables store references, not the object’s contents directly.

11
New cards

Reference variable

A variable of a class type that holds a reference (address/handle) to an object in memory, or null.

12
New cards

Aliasing

When two reference variables refer to the same object (e.g., b = a; copies the reference, not the object).

13
New cards

null

A literal meaning “no object”; can be assigned to any reference variable.

14
New cards

NullPointerException

A runtime error that occurs when you try to use null like an object (e.g., calling a method on a null reference).

15
New cards

Empty string ("")

A real String object with length 0; it is not the same as null.

16
New cards

new keyword

Allocates a new object in memory and returns a reference to it (e.g., new Scanner(System.in)).

17
New cards

Constructor

Special code that runs when an object is created; has the same name as the class, has no return type, and may take parameters (can be overloaded).

18
New cards

Scanner

A Java library class used to read input; commonly constructed as new Scanner(System.in) and then used via instance methods.

19
New cards

Dot operator (.)

Used to call an instance method/field on an object reference: objectRef.methodName(args).

20
New cards

Parameter

A variable in a method/constructor definition that receives a value when the method/constructor is called.

21
New cards

Argument

The actual value passed into a method/constructor call (e.g., in s.substring(2,5), 2 and 5 are arguments).

22
New cards

Void method

A method that performs an action but returns no value (cannot be stored/used as an expression), e.g., println(…).

23
New cards

Non-void method

A method that returns a value; the call evaluates to that value and can be stored or used in expressions (e.g., s.length()).

24
New cards

Return type

The type of value a non-void method produces (e.g., length() returns int; substring(…) returns String).

25
New cards

Method chaining

Calling a method on the object returned by a previous method call (e.g., "hello".toUpperCase().substring(1)).

26
New cards

String

A Java class representing text; String values are objects with many commonly tested methods (length, substring, indexOf, equals, compareTo).

27
New cards

String immutability

Strings cannot be changed after creation; most String methods return a new String rather than modifying the original.

28
New cards

0-based indexing

String character positions start at 0; the last valid index is length() - 1.

29
New cards

StringIndexOutOfBoundsException

A runtime error caused by using an invalid String index (e.g., negative or ≥ length()).

30
New cards

String.length()

Returns the number of characters in a String as an int (spaces count as characters).

31
New cards

String.substring(int beginIndex)

Returns a new String from beginIndex to the end of the original String.

32
New cards

String.substring(int beginIndex, int endIndex)

Returns a new String from beginIndex up to (but not including) endIndex.

33
New cards

Exclusive endIndex (substring rule)

In substring(beginIndex, endIndex), the character at endIndex is not included; endIndex is one past the last included index.

34
New cards

String.indexOf(…)

Searches for a character/substring and returns the index of the first occurrence; returns -1 if not found.

35
New cards

String.equals(…)

Compares String contents (characters) for equality; use this instead of == for text comparison.

36
New cards

== operator (reference comparison)

For objects, checks whether two references point to the same object (not whether contents match); unreliable for String content comparison.

37
New cards

String.compareTo(…)

Lexicographically compares two strings and returns an int: negative if calling string comes before, 0 if equal, positive if after.

38
New cards

Wrapper class

An object type that wraps a primitive value (e.g., Integer for int, Double for double, Boolean for boolean).

39
New cards

Autoboxing

Automatic conversion from a primitive to its wrapper (e.g., Integer a = 7;).

40
New cards

Unboxing

Automatic conversion from a wrapper object to its primitive (e.g., int b = a;).

41
New cards

Integer.parseInt(String)

Converts a numeric String into an int; throws NumberFormatException if the String is not a valid integer.

42
New cards

Double.parseDouble(String)

Converts a numeric String into a double; throws NumberFormatException if the String is not a valid number.

43
New cards

NumberFormatException

A runtime error thrown when parsing a String into a number fails due to invalid format.

44
New cards

Unboxing null pitfall

If a wrapper reference is null and Java tries to unbox it to a primitive, a NullPointerException occurs (e.g., Integer n=null; int x=n;).

45
New cards

Math class

A utility class of static math methods (no Math objects are created); methods are called like Math.methodName(…).

46
New cards

Math.sqrt(x)

Static method that returns the square root of x as a double (even if x is an int).

47
New cards

Math.pow(a, b)

Static method that returns a raised to the power b as a double.

48
New cards

Math.random()

Returns a double in the range [0.0, 1.0), meaning 0.0 is possible but 1.0 is not.

49
New cards

Casting to int (truncation)

(int) applied to a double drops the decimal part (truncates toward 0); it does not round.

50
New cards

Random integer patterns with Math.random()

Common patterns: 0..n-1: (int)(Math.random()n). a..b inclusive: (int)(Math.random()(b-a+1))+a. Pitfall: (int)Math.random()*n casts too early and usually becomes 0.

Explore top notes

note
Invisible Man Chapter 1
Updated 1173d ago
0.0(0)
note
Media & Information Literacy
Updated 322d ago
0.0(0)
note
Invisible Man Chapter 7
Updated 1173d ago
0.0(0)
note
Unit 3 : Macromolecules
Updated 313d ago
0.0(0)
note
International Cooperation
Updated 1195d ago
0.0(0)
note
Biochimie
Updated 746d ago
0.0(0)
note
Invisible Man Chapter 1
Updated 1173d ago
0.0(0)
note
Media & Information Literacy
Updated 322d ago
0.0(0)
note
Invisible Man Chapter 7
Updated 1173d ago
0.0(0)
note
Unit 3 : Macromolecules
Updated 313d ago
0.0(0)
note
International Cooperation
Updated 1195d ago
0.0(0)
note
Biochimie
Updated 746d ago
0.0(0)

Explore top flashcards

flashcards
S.S. Unit 3 - Study Guide
57
Updated 126d ago
0.0(0)
flashcards
Chapter 27
120
Updated 705d ago
0.0(0)
flashcards
Lit Words: 2 The Boogaloo
24
Updated 496d ago
0.0(0)
flashcards
Lab Practical 3
75
Updated 755d ago
0.0(0)
flashcards
Polyatomic Ions
21
Updated 768d ago
0.0(0)
flashcards
Latin Week 5
26
Updated 920d ago
0.0(0)
flashcards
Connect 4, Unit 3
52
Updated 1011d ago
0.0(0)
flashcards
S.S. Unit 3 - Study Guide
57
Updated 126d ago
0.0(0)
flashcards
Chapter 27
120
Updated 705d ago
0.0(0)
flashcards
Lit Words: 2 The Boogaloo
24
Updated 496d ago
0.0(0)
flashcards
Lab Practical 3
75
Updated 755d ago
0.0(0)
flashcards
Polyatomic Ions
21
Updated 768d ago
0.0(0)
flashcards
Latin Week 5
26
Updated 920d ago
0.0(0)
flashcards
Connect 4, Unit 3
52
Updated 1011d ago
0.0(0)