What is the result of the following?
ArrayList<Integer> list = new ArrayList<>(); list.add(5); list.add(5); list.add(3); TreeSet<Integer> set = new TreeSet<>(list); System.out.print(set.size()); System.out.print(" " ); System.out.print(set.iterator().next());
A.
First the code creates an ArrayList of three elements.
Then the list is transformed into a TreeSet.
Since sets are not allowed to have duplicates, the set only has two elements.
A TreeSet is sorted, which means that the first element in the TreeSet is 3.
Option A is correct.