Home / Programming MCQs / JAVA MCQs / Question

T

Tina Singh • 10.59K Points
Tutor II

Q. What will be the output of given code

Code:
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

public class ConcurrentSkipListMapTest {
public static void main (String args)
{
Set set = new TreeSet();
set.add(1);
set.add(“2”);
set.add(3);

Iterator iterator = set.iterator();
while (iterator. hasNext())
{
System. out. print(iterator. next()+””);
}
}

}
(A) 1 2 3
(B) 1 followed by exception
(C) Compile time exception
(D) 3 2 1

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.