What will be the result of attempting to compile and run the following code?
public class Main { public static void main(String[] args) { Set set = new TreeSet<String>(); set.add("one"); set.add(2); set.add("three"); System.out.println(set); } }
Select the one correct answer.
(d)
The compiler issues unchecked warnings for calls to the add()
method.
The TreeSet class orders elements according to their natural ordering.
A ClassCastException is thrown at runtime, as Strings are not comparable to Integers.