Java String Method Behavior
Consider the following code segment.
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 is accomplished by this code segment?
A
It finds and extracts the substring “GRAM” from the original string
B
It counts the number of characters between “GRAM” and the end of the string
C
It creates a new string by removing “GRAM” from the original string
D
It replaces all occurrences of “GRAM” with a 4-character substring
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | ansonjia1371 | 2 | 2 | 0m 00s | 200 |
| #2 | zgj07310417 | 0 | 1 | 0m 36s | -46 |
| #3 | lsj08030922 | 1 | 1 | 4m 03s | -143 |
Items per page:
10
1 – 3 of 3
