Which of the following statements are true? (Select two.)
3: Set<Number> numbers = new HashSet<>(); 4: numbers.add(new Integer(86)); 5: numbers.add(75); 6: numbers.add(new Integer(86)); 7: numbers.add(null); 8: numbers.add(309L); 9: Iterator iter = numbers.iterator(); 10: while (iter.hasNext()) 11: System.out.print(iter.next());
A, D.
The code compiles fine.
It uses the diamond operator, and it allows any implementation of Number to be added.
HashSet does not guarantee any iteration order, making A and D correct.