Vidyalelo
Java Programming · Q126

Java Collections Framework

Programming · Java Programming · question 126

Q126

What will be the output of the following Java program? import java.util.*; class Collection_Algos 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(); while(i.hasNext()) System.out.print(i.next() + " ");

A.
2 8 5 1
Answer
B.
1 5 8 2
C.
2
D.
2 1 8 5

Answer: Option A

Solution

Answer: Option A
No explanation is given for this question Let's Discuss on Board