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"
What is the value of the string newVal?: String newVal = "5" + 3;
53
8
"53"
"8"
How do you convert all characters in a string object to lowercase in Java?
toUpperCase()
.toLowerCase()
.toUpperCase()
toLowerCase()
What does a substring(0, n)
call on a string return?
The first n
characters of that string.
All characters after index n until the end.
The entire original string unchanged.
A random substring within the original string.
Which code segment will replace all occurrences of letter 'x' with letter 'o' in a given String str?
str.toCharArray("o").toString()
str.replaceFirst("x", o")
("x".replaceIn(str, o")
str.replaceAll("x", "o")
Which of the following instantiates a new empty StringBuilder object?
new StringBuilder("")
StringBuilder.new()
StringBuilder.empty()
new StringBuilder()
If you execute String s = new StringBuilder("recursion").reverse().toString().toUpperCase();
, what value does s represent?
NOISRECURESION
NOISRUERC
RECURSION
RECUSRION

How are we doing?
Give us your feedback and let us know how we can improve
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));
What method is called when concatenating objects to strings?
concat()
toString()
equals()
length()
How does substring(int beginIndex, int endIndex) behave if beginIndex equals endIndex?
A single-character string starting at beginIndex is returned.
An empty string is returned.
endIndex character alone makes up the new string.
IllegalArgumentException is thrown.