Question 1 of 5
Let word store bridge.
(a) State the value of word.substring(2, 5). (b) Explain why the 5 is not included in that result. (c) State the length of that substring.
Responses receive AI feedback against a rubric after submission. Scores are practice estimates.
Let word store bridge.
(a) State the value of word.substring(2, 5). (b) Explain why the 5 is not included in that result. (c) State the length of that substring.
Complete the missing cells for this character count. Then state the final value of n.
String s = "green";
int n = 0;
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == 'e') {
n++;
}
}
| i | charAt(i) | n after this iteration |
|---|---|---|
| 0 | g | |
| 1 | r | |
| 2 | e | |
| 3 | e | |
| 4 | n |
Reverse the characters of lamp using a loop over indices.
(a) Write Java that stores the reverse in an int-index loop using charAt or substring and concatenation. (b) State the stored reverse. (c) Explain why the loop starts at length() - 1.
Count overlapping occurrences of ll in helloall.
(a) Write a for loop that inspects every substring of length 2 and increments hits when that piece equals ll. (b) State the final value of hits. (c) Explain why the last starting index is length() - 2.
Let msg store catalog.
(a) State the value of msg.indexOf("log"). (b) State the value of msg.substring from that index through the end of msg. (c) Write an if that prints hit when the last three characters equal log, using substring and equals.