AP Computer Science A Resource
Strings practice guide
A focused AP Computer Science A guide for String traversal, substring boundaries, comparison, and common string-building patterns.
Study Snapshot
AP unit
Units 1-2
Exam use
String APIs, loops, tracing, and FRQ helpers
Study time
35-45 min
Resource Navigator
Move through AP Computer Science A by skill
Best used when
Students who lose points on indexes, substring endpoints, equals vs ==, or loop boundaries.
String API Essentials
These methods appear constantly in AP-style tracing and implementation problems.
length() returns the number of characters.
charAt(index) returns one character at a zero-based index.
substring(start, end) includes start and excludes end.
indexOf(target) returns the first location or -1 when not found.
equals(other) compares content; == compares references.
String word = "computer";
System.out.println(word.length()); // 8
System.out.println(word.charAt(3)); // p
System.out.println(word.substring(1, 4)); // omp
System.out.println(word.indexOf("put")); // 3Traversal Patterns
Most String FRQ work is a careful loop with a small decision inside.
Count characters by scanning from 0 to length() - 1.
Build a new String when removing or replacing characters.
Use substring(i, i + 1) when the prompt expects String values instead of char values.
Check bounds before reading i + 1 or i - 1.
int count = 0;
for (int i = 0; i < word.length(); i++) {
if (word.charAt(i) == 'a') {
count++;
}
}FRQ Moves
AP questions reward small, predictable method-writing habits.
Name helper variables from the prompt so your logic is easy to read.
Return early only when it makes the method clearer.
Test empty strings, one-character strings, and strings with repeated characters.
After writing the loop, trace it once with a table of i, current character, and result.
Practice checklist
Use these prompts as a short self-check before moving back into FRQs or class assignments.
For practice use only.
AP Computer Science A Strings Hard MCQ Practice
Practice hard AP Computer Science A String tracing, substring boundaries, indexOf reasoning, compareTo, equals versus ==, immutability, nested loops, and pattern detection.
Answered 0 of 25
Choose one answer.
What is printed by the following code?
String s = "abracadabra";
int p = s.indexOf("ra");
System.out.print(s.substring(p, p + 4));Need help applying this?
