Using Objects in AP Computer Science A
What does "Computer".substring(0,3) return?
Com
pute
uter
Comp
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
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)
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
Given String str = "Test123Test";
, what does str.substring(4,7)
return?
"Test"
Throws an IndexOutOfBoundsException
"123"
"123Test"
To access a substring of a string, what indices do you need to specify in the substring() method?
beginIndex and endIndex
beginIndex
endIndex
beginIndex and length

How are we doing?
Give us your feedback and let us know how we can improve
What is returned when calling "Hello".indexOf('o')?
2
4
-1
6
Given the code snippet String phrase = "StudySession";
, which operation would return the index of the first occurrence of 'S' after the fifth position?
phrase.lastIndexOf('S')
phrase.indexOf('S')
phrase.charAt(5)
phrase.indexOf('S',5)
What is returned when calling the indexOf() function on string 'compute' with argument āpā ?
indexOf('compute', 'p')
compute.indexOf('p')
computer.find('p')
compute.charAt('p')