AP CSA Unit 1 Built-In Classes: Strings, Math, APIs, and Comments

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/24

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

25 Terms

1
New cards

String (Java)

An object representing a sequence of characters (letters, digits, punctuation, spaces); variables of type String store a reference to a String object.

2
New cards

Immutable (String immutability)

A property meaning a String cannot be changed after it’s created; any “modification” method produces a new String object.

3
New cards

String literal

A String value written directly in code using quotes, e.g., "Ava" or "".

4
New cards

Concatenation

Joining strings together, commonly using the + operator (e.g., "Hello, " + name).

5
New cards

String conversion (with +)

When one operand of + is a String, Java converts the other operand to a String and concatenates.

6
New cards

Evaluation order pitfall (String + numbers)

Once concatenation with a String starts, later + operations concatenate as text unless parentheses force arithmetic ("Sum: " + 2 + 3 → "Sum: 23").

7
New cards

length()

A String instance method that returns the number of characters in the string (counts spaces/punctuation too).

8
New cards

Valid String indices

For a String of length n, the valid character indices are 0 through n − 1.

9
New cards

Off-by-one error

A common indexing mistake where code uses an index one too high/low (often forgetting indices stop at length() − 1 or end index is exclusive).

10
New cards

substring(int from, int to)

Returns a new String slice starting at index from (inclusive) and stopping before index to (exclusive).

11
New cards

substring(int from)

Returns a new String from index from (inclusive) to the end of the original string.

12
New cards

Exclusive end index (substring)

In substring(from, to), the character at index to is NOT included; to is the first index not taken.

13
New cards

StringIndexOutOfBoundsException

A runtime error that occurs when substring/char indexing uses an index outside 0..length() (or violates from/to rules).

14
New cards

indexOf(String str)

A String method that returns the index of the first occurrence of str, or -1 if not found.

15
New cards

indexOf(String str, int fromIndex)

An overloaded indexOf that begins searching at fromIndex; returns first match at/after that position, or -1 if not found.

16
New cards

Sentinel value -1 (indexOf)

The value returned by indexOf when the search string is not found; must be checked before using the result as an index.

17
New cards

equals(String other)

A String method that returns true if two strings have the same characters in the same order (content comparison).

18
New cards

== vs equals (Strings)

== compares references (same object); equals compares contents (same characters).

19
New cards

compareTo(String other)

Compares strings in lexicographic (dictionary) order; returns

20
New cards

Lexicographic order (case sensitivity)

Ordering based on character codes; uppercase letters typically come before lowercase, affecting compareTo results.

21
New cards

Static method

A method called using the class name (not an instance), e.g., Math.sqrt(81); you do not create an object to use it.

22
New cards

Math.abs(x)

A static Math method that returns the absolute value of x (distance from 0).

23
New cards

Math.pow(a, b)

A static Math method that returns a^b as a double (even if inputs look like integers).

24
New cards

Math.random()

A static Math method that returns a pseudorandom double in the range [0.0, 1.0) (0.0 inclusive, 1.0 exclusive).

25
New cards

Random integer range formula

To get an int from min to max inclusive: (int)(Math.random() * (max - min + 1)) + min (cast after scaling).

Explore top notes

note
RIse of Democracy Vocab Pt. 3
Updated 1507d ago
0.0(0)
note
KOREAN - IMPORTANT VOCABULARY
Updated 1262d ago
0.0(0)
note
Indirect Values
Updated 1507d ago
0.0(0)
note
biology
Updated 1941d ago
0.0(0)
note
Factorisation (copy)
Updated 1081d ago
0.0(0)
note
Chapter 9 - Jacksonian Era
Updated 1444d ago
0.0(0)
note
Hello
Updated 1195d ago
0.0(0)
note
RIse of Democracy Vocab Pt. 3
Updated 1507d ago
0.0(0)
note
KOREAN - IMPORTANT VOCABULARY
Updated 1262d ago
0.0(0)
note
Indirect Values
Updated 1507d ago
0.0(0)
note
biology
Updated 1941d ago
0.0(0)
note
Factorisation (copy)
Updated 1081d ago
0.0(0)
note
Chapter 9 - Jacksonian Era
Updated 1444d ago
0.0(0)
note
Hello
Updated 1195d ago
0.0(0)

Explore top flashcards

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