Question: Consider the following method. publ ic stat ic St r ing abMethod ( St r ing a , St r ing b ) { int

Consider the following method.
publ ic stat ic St r ing abMethod(St r ing a, St r ing b)
{
int x = a. indexOf(b) ;
whi le (x >=0)
{
a = a.subst r ing(0, x)+ a.subst r ing(x + b. length()) ;
x = a. indexOf(b) ;
}
return a;
}
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 St r ingIndexOutOfBoundsExcept ion is thrown

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!