Question: The second and final time inside the loop while, a.substring(x+b.length()) is out of bounds because x+b.length() is 11 while a.length() = 10. Please explain clearly
The second and final time inside the loop while, a.substring(x+b.length()) is out of bounds because x+b.length() is 11 while a.length() = 10. Please explain clearly why it is not out of bounds. Correct answer is B. 28. Consider the following method. public static String abMethod(String a, String b) int x = a.indexOf(b); while (x >= 0) { a = a.substring(o, x) + a.substring(x + b. length(); x = a.indexOf(b); } return a; 1 What, if anything, is returned by the method call abMethod("sing the song", "ng") ? (A) "si" (B) "si the so" (C) "si the song " (D) "sig the sog" (E) Nothing is returned because a StringIndexOutOfBoundsException is thrown
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
