What will be the output of the following program?

TreeSet set = new TreeSet<>();
set.add("apple");
set.add("banana");
set.add("cherry");
set.add("date");
set.add("banana");
Iterator iterator = set.iterator();
while (iterator.hasNext()) {
    System.out.print(iterator.next() + " ");
}

1
apple banana cherry date
2
date cherry banana apple
3
banana apple date cherry
4
apple banana cherry date banana
5
Question Not Attempted

Sponsored

hivanix.in

Visit

This quiz is brought to you by hivanix.in

🌐 Web App Development

Quick Navigation