Using Objects in AP Computer Science A
How many unique substrings can be formed from "boolean" that include both characters 'b' and 'n' exactly once?
One - "bool"
Three - None can be formed as specified.
Two - "boolea" and "boolean"
One - "boolean"
If a string variable word
contains "examination", which of the following code segments will correctly output "nation"?
System.out.println(word.substring(7));
System.out.println(word.substring(5, word.length() - 1));
System.out.println(word.substring(0, word.length() - 5));
System.out.println(word.substring(5));
Which method would you use to compare two strings for equality in Java?
.equal()
.equals()
.compareTo()
.equalsIgnoreCase()
What is the result of concatenating two strings, "Java" and "Fun", using the '+' operator?
8
"JavaFun"
"Java Fun"
"JavFun"
Consider a string object defined as follows String sequence = “0102010”;
, which operation would correctly determine how many times ‘02’ appears in sequence?
(sequence.length() - sequence.replace("02", "").length()) / ("02".length())
sequence.split("02").length -
(sequence.length() - sequence.replaceAll("[^02]", "").length()) / (2)
sequence.indexOf("02020") != -
How do you find the length of a string "Hello" in Java?
5
4
6
"Hello".length()
If you want to convert an integer variable named score to a String, which method would you use?
String.toInt(score)
Integer.toString(score)
score.toString()
toString(score)

How are we doing?
Give us your feedback and let us know how we can improve
What does the expression "ComputerScience".substring(8).length() return?
10
7
9
8
How do you convert all characters in a string object to lowercase in Java?
toUpperCase()
.toLowerCase()
.toUpperCase()
toLowerCase()
If you execute String s = new StringBuilder("recursion").reverse().toString().toUpperCase();
, what value does s represent?
NOISRECURESION
NOISRUERC
RECURSION
RECUSRION