Question: Consider the following method. publ ic stat ic St r ing [ ] st rArrMethod ( St r ing [ ] arr ) { St

Consider the following method.
publ ic stat ic St r ing[] st rArrMethod(St r ing[] arr)
{
St r ing[] resul t = new St r ing[arr . length] ;
for ( int j =0; j < arr . length; j++)
{
St r ing sm = arr[ j ] ;
for ( int k = j +1; k < arr . length; k++)
{
i f (arr[k]. length()< sm. length())
{
sm = arr[k] ; // Line 12
}
}
resul t [ j ]= sm;
}
return resul t ;
}
21. Consider the following code segment.
St r ing[] testOne ={"first", "day", "of","spr ing"};
St r ing[] resul tOne = st rArrMethod( testOne) ;
What are the contents of resul tOne when the code segment has been executed?
(A){"day", "first", "of","spr ing"}
(B){"of", "day", "first", "spr ing"}
(C){"of", "day", "of","spr ing"}
(D){"of","of","of","spr ing"}
(E){"spr ing", "first", "day", "of"}

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!