Implementing String Algorithms FRQ Practice

Responses receive AI feedback against a rubric after submission. Scores are practice estimates.

Question 1 of 5

Let place store window.

(a) State the value of place.substring(2, 6). (b) Explain why index 6 is not a kept character. (c) State the value of place.charAt(2) and relate it to the first character of that substring.

Question 2 of 5

Count how many times the character s appears in mississippi.

(a) Write a loop over indices that increments hits when charAt(i) is 's'. (b) State the final value of hits. (c) Explain why the loop condition uses i < s.length() rather than <=.

Question 3 of 5

Reverse the characters of code.

(a) Write a while or for loop that stores the reverse in rev using charAt or substring. (b) State the stored reverse. (c) Explain how concatenation order produces the reverse instead of a copy.

Question 4 of 5

Count overlapping occurrences of ee in beetleek.

(a) Write a loop that inspects every two-character substring and increments hits when the piece equals ee. (b) State the final value of hits. (c) Identify the starting indices where those matches occur.

Question 5 of 5

Let phrase store concatenate.

(a) State the value of phrase.indexOf("cat"). (b) State the value of phrase.substring(3, 6). (c) Write an if using compareTo or equals that prints found when substring(3, 6) is the same string as cat.