Multiple Choice
Which of the following creates the string of the numbers from 1 to 1000 most efficiently?
A) String s;
for (int i = 1; i <= 1000; i++)
S += i;
B) StringBuilder sb = new StringBuilder(10) ;
for (int i = 1; i <= 1000; i++)
Sb) append(i) ;
String s = new String(sb) ;
C) StringBuilder sb = new StringBuilder(3000) ;
for (int i = 1; i <= 1000; i++)
Sb) append(i) ;
String s = new String(sb) ;
D) All are equivalently efficient.
Correct Answer:

Verified
Correct Answer:
Verified
Q16: To find the character at a certain
Q17: StringBuilder objects can be used in place
Q18: Given the following declarations: <br>StringBuilder buffer =
Q19: Which of the following is not a
Q20: Which of the following statements is true?<br>A)
Q21: How many String objects are instantiated by
Q22: Consider the Java segment: <br>String line1 =
Q24: Consider the String below: <br>String r =
Q25: Which of the following will create a
Q26: String objects are immutable. This means they