Home » JAVA Programming » Collections » Question
  1. What is the output of this program?
    import java.util.*;
    public class Collection_AlgorithmsExample
    {
    public static void main(String args[])
    {
    LinkedList listObject = new LinkedList();
    listObject.add(new Integer(2));
    listObject.add(new Integer(8));
    listObject.add(new Integer(5));
    listObject.add(new Integer(1));
    Iterator Itr = listObject.iterator();
    while(Itr.hasNext())
    System.out.print(Itr.next() + " ");
    }
    }
    1. 25 28 52 31
    2. 55 31 28 25
    3. 31 55 28 25
    4. 28 25 55 31
    5. None of these
Correct Option: A

25 28 52 31



Your comments will be displayed only after manual approval.