

Objects and Collections - Programming
Q1: What will be the output of the program?
TreeSet map = new TreeSet();
map.add('one');
map.add('two');
map.add('three');
map.add('four');
map.add('one');
Iterator it = map.iterator();
while (it.hasNext() )
{
System.out.print( it.next() + ' ' );
}
A one two three four
B four three two one
C four one three two
D one two three four one
ANS:A - one two three four TreeSet assures no duplicate entries; also, when it is accessed it will return elements in natural order, which typically means alphabetical. |


For help Students Orientation
Mcqs Questions
One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.