Java String Method Behavior
Identify the attributes and behaviors of a class found in the libraries contained in an API.
A programmer is working with the String class and writes the following code:
String word = "PROGRAMMING";
int pos = word.indexOf("GRAM");
String result = word.substring(pos, pos + 4);
System.out.println(result);
Which of the following best describes what this code accomplishes?
A
It creates a new string by removing “GRAM” from the original string
B
It counts the number of characters between “GRAM” and the end of the string
C
It finds and extracts the substring “GRAM” from the original string
D
It replaces all occurrences of “GRAM” with a 4-character substring
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE