-
What is the output of this program?
import java.util.*;
public class Collection_AlgosExample
{
public static void main(String args[])
{
LinkedList listobject = new LinkedList();
listobject.add(new Integer(13));
listobject.add(new Integer(23));
listobject.add(new Integer(3));
listobject.add(new Integer(11));
Iterator Itr = listobject.iterator();
Collections.reverse(listobject);
Collections.sort(listobject);
while(Itr.hasNext())
System.out.print(Itr.next() + " ");
}
}
-
- 3 11 13 23
- 13 23 3 11
- 3 11 13
- 13 11 3
- 23 13 11 3
Correct Option: A
Collections.sort(list) sorts the given list, the list was 13->23->3->11 after sorting it became 3->11->13->23.