Solved

Which of the Following Creates the String of the Numbers

Question 2

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

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents