Vote count:
0
I am brand new to APCS and am practicing for my test. After analyzing this code with a step-by-step analysis, I'm convinced that the answer isn't listed below but is instead "S". However, my teacher says that the answer is 'D'
Can you explain to me this question?
Given the following method:
public static String WhatsUp (String str1, String str2)
{
int index = str1.indexOf(str2);
if (index != -1)
str1 = str1.substring(0, index) +
str1.substring(index + str2.length());
return str1;
}
What does this line of code output?
System.out.print( WhatsUp(“SpongeBobSquarePants”, “S”));
(A) pongeBobquarePants
(B) pongeBobquarePant
(C) SpongeBobSquarePants
(D) pongeBobSquarePants
(E) Patrick
asked 31 secs ago
Why does this code not return just "S" but instead the whole String MINUS the "S"
Aucun commentaire:
Enregistrer un commentaire