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
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)