Solved

Which of the Following Creates the String of the Numbers

Question 23

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:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions