AP CSA String methods practice
AP CSA String Methods Practice
String questions look small, but they punish loose index reasoning. Students need to know what each method returns, when an index is included or excluded, and how a loop changes the result one character at a time.
Best For
When to use this page
Students who miss substring endpoints, forget that indexOf can return -1, compare Strings with ==, or lose track of loop bounds.
Practice Prompts
Try these before moving on
1
Trace a loop that builds a new String by skipping every second character.
2
Write a method that returns the part of a String before the first dash, handling the no-dash case.
3
Find and explain the bug in code that calls substring(indexOf(target), indexOf(target) + 1) without checking for -1.
Common Mistakes
What to check in your answer
Treating substring end indexes as inclusive.
Using == instead of equals for content comparison.
Calling charAt(i + 1) without proving i + 1 is valid.
