P

Pradeep Sikarwar • 9.01K Points
Tutor III

Q. What will be the output of the following code

Code:
import java.util.Arrays;
import java.util.Comparator;
public class ComparatorTest {
public static void main(String args[])
{
String[] ar= {“c”,”d”,”b”,”a”,”e”};
InnerClass in=new InnerClass();
Arrays.parallelSort(ar, in);
for(String str : ar)
System.out.println(str +””);
System.out.println(Arrays.binarySearch(ar, “b”));
}
static class InnerClass implements Comparator<String>
{
public int compare(String s1, String s2)
{
return s2.compareTo(s1);
}
}
}
  • (A) e d c b a -1
  • (B) a b c 0 e d
  • (C) d b c e a 1
  • (D) e b a d c

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.