Using Objects in AP Computer Science A
What does "Computer".substring(0,3) return?
Com
pute
uter
Comp
What method would you use to check if two strings are equal, ignoring the case?
equalsIgnoreCase(String other)
isSame(String other)
equalsWithoutCase(String other)
withoutCaseEquals(String other)
Considering String s = "iteration";
, what is the result of s.length() + s.indexOf('n')
?
19
Throws an IndexOutOfBoundsException.
Compiles with an error.
18
Which method returns a substring from index start
up to but not including index end
from the string info
?
info.getSubstring(start, end)
info.subString(start, end)
info.substring(start, end)
substring(info, start, end)
What must be true about a non-empty string str
if (str.substring(0, k) + str.substring(k)).equals(str)
holds for all values of k where 0 <= k <= str.length()
?
Str must contain at least one instance where contiguous characters are identical so substrings can join without loss informationally.
The string str must end with its starting character sequence up to length k-1 for correct alignment during concatenation checks against itself.
This condition will always hold true regardless of what str contains due to how substring concatenation works in Java.
Str must consist solely of repeating characters so that substring division doesn't affect equality comparison with original str.
Considering algorithms that concatenate characters from two strings alternatively (e.g., “abc” + “123” = “a1b2c3”), which method would be least efficient if implemented in Java?
An algorithm employing char arrays and building the result with a single pass through both arrays
An algorithm that uses pre-allocation of space by initializing StringBuilder with capacity
An algorithm using repeated concatenation with the ‘+’ operator inside a loop
An algorithm utilizing a StringBuilder appended inside a loop
What is the index of the first character of a string?
1
0
-1
The index depends on the length of the string

How are we doing?
Give us your feedback and let us know how we can improve
Given two strings, strA = "APCALCULUS" and strB = "APPHYSICS", what will be the output for strA.compareTo(strB)?
Positive number less than or equal to ten
Negative number greater than -10
Positive integer more than ten
Zero
Which control structure should be utilized when determining whether a given string input
starts with a certain prefix, without iterating through each character?
for loop
if statement
do-while loop
switch statement
Which statement will return true if a given string variable phrase contains at least three consecutive vowels anywhere within it?
"[aeiou]{3}".equals(phrase)
phrase.contains("[aeiou][aeiou][aeiou]")
phrase.matches(".[aeiou]{3}.")
phrase.indexOf("[aeiou]{3}") != -1