Question: import java.util.*; public class SortOf { public static void main(String[] args) { ArrayList a = new ArrayList (); a.add(1); a.add(5); a.add(3); Collections.sort(a); a.add(2); Collections.reverse(a); System.out.println(a);

import java.util.*;

public class SortOf {

public static void main(String[] args) {

ArrayList a = new ArrayList();

a.add(1); a.add(5); a.add(3);

Collections.sort(a);

a.add(2);

Collections.reverse(a);

System.out.println(a);

}

} What is the result? A. [1, 2, 3, 5]

B. [2, 1, 3, 5]

C. [2, 5, 3, 1]

D. [5, 3, 2, 1]

E. [1, 3, 5, 2]

F. Compilation fails.

G. An exception is thrown at runtime

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 Databases Questions!