What is the result of the following code?
TreeSet<String> tree = new TreeSet<String>(); tree.add("one"); tree.add("One"); tree.add("ONE"); System.out.println(tree.ceiling("On"));
C.
TreeSet sorts the elements.
Since uppercase letters sort before lowercase letters, the ordering is "ONE", "One", "one".
The ceiling()
method returns the smallest element greater than the specified one.
"On" appears between "ONE" and "One".
Therefore, the smallest element that is larger than the specified value is "One".