94.7k views
4 votes
Public static String doSomething(String s) { final String BLANK = " "; //BLANK contains a single space String str = ""; //empty string String temp; for (int i = 0; i < s.length(); i++) { temp = s.substring(i, i + 1); if (!(temp.equals(BLANK))) str += temp;

}
return str;
}
Which of the following is themost precise description ofwhat doSomething does?
A. It returns a String that contains s.length() blanks.
B. It returns s with all its blanks removed.
C. It returns s unchanged.
D. It returns a String that is equivalent to s with all its blanks removed.
E. It returns a String that is an exact copy of s.

User Cluster
by
4.9k points

1 Answer

3 votes

Answer:

D. It returns a String that is equivalent to s with all its blanks removed

Step-by-step explanation:

Public static String doSomething(String s) { final String BLANK = " "; //BLANK-example-1
User BillMan
by
5.2k points