Which expression will determine the number of characters in a String object call
ID: 3740598 • Letter: W
Question
Which expression will determine the number of characters in a String object called longword?
longword.length()
longword.length
charAt(longword)
getChars(longword)
If you know you will need to increase the capacity of a StringBuilder object multiple times in a program, it's best to set the initial capacity _____.
high
very precisely
low
to an empty string
You are comparing two String variables, t1 and t2. Which statement is equivalent to the one below?
t1.regionMatches(true, 0, s4, 0, t2.length());
t1.regionMatches(false, t2, 0, t1.length);
t1.regionMatches(0, t2.length());
t1.equalsIgnoreCase(t2);
t1.compareTo(t2.length);
When the String method substring takes two arguments, the second argument is the _______.
length of the string
index after the last character to include
number of characters to include
index of the last character to include
When variable references are compared with ==, the result is true is if both their _______ are identical.
class names
memory locations
actual contents
relative values
Interface [answer] describes methods for writing primitive types to an output stream.
longword.length()
longword.length
charAt(longword)
getChars(longword)
Explanation / Answer
If you post more than 1 question, as per chegg guidelines I have to answer only first question.
Ques 1. The function to get the length of a String is length().
So, Answer : (a) longword.length()
Ques 4.Answer : (b) index after the last character to include
The substring method is
String substring(int beginIndex, int endIndex)
endIndex is not included.
Ques 5. == operator returns true when the references ot the memory locations are same. If we want to compare the contents of STring, we use equals() method.
Answer : (b) memory locations
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.