Q. What will be the output of given code

Code:
import java. util.Arrays;
import java. util.Comparator;
class Sorting implements Comparator
{
public int compare(Integer o1, Integer o2)
{
return o2. compareTo(o1);
}
}
public class abc {
public static void main (String…a)
{
Integer intArray[]= {2,3,1};
Arrays.sort(intArray, new Sorting());
for(int i: intArray)
{
System. out. print(i+””);
}
}
}
  • (A) Compile time exception
  • (B) 3 2 1
  • (C) 1 2 3
  • (D) 2 3 1
πŸ’¬ Discuss
βœ… Correct Answer: (B) 3 2 1

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
255
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Tina Singh
Publisher
πŸ“ˆ
82%
Success Rate