What will the program print when it is compiled and run?
import static java.lang.System.out; import java.util.Collections; import java.util.NavigableSet; import java.util.TreeSet; public class Main { public static void main(String[] args) { NavigableSet<String> strSetA = new TreeSet<String>(); Collections.addAll(strSetA, "set", "shell", "soap"); out.print(strSetA.ceiling("shell") + " "); out.print(strSetA.floor("shell") + " "); out.print(strSetA.higher("shell") + " "); out.println(strSetA.lower("shell")); } }
Select the one correct answer.
(c), (d), (e), and (f)
Sets cannot have duplicates.
HashSet does not guarantee the order of the elements in (a) and (b), therefore there is no guarantee that the program will print [1, 9].
Because LinkedHashSet maintains elements in insertion order in (c) and (d), the program is guaranteed to print [1, 9].
Because TreeSet maintains elements sorted according to the natural ordering in (e) and (f), the program is guaranteed to print [1, 9].