What is the output of the following Java program?

     import java.util.*;
    class Collection_iterators 
    {
        public static void main(String args[]) 
        {
            LinkedList list = new LinkedList();
            list.add(new Integer(2));
            list.add(new Integer(8));
            list.add(new Integer(5));
            list.add(new Integer(1));
            Iterator i = list.iterator();
            Collections.reverse(list);
    Collections.sort(list);
            while(i.hasNext())
        System.out.print(i.next() + " ");
        }
    }

1
2 8 5 1
2
1 5 8 2
3
2 1 8 5
4
1 2 5 8
5
Question Not Attempted

Sponsored

hivanix.in

Visit

This quiz is brought to you by hivanix.in

🌐 Web App Development

Quick Navigation