Given the proper import statement(s) and:
13. TreeSet<String> s = new TreeSet<String>(); 14. TreeSet<String> subs = new TreeSet<String>(); 15. s.add("a"); s.add("b"); s.add("c"); s.add("d"); s.add("e"); 16.//from ww w. java 2 s .com 17. subs = (TreeSet)s.subSet("b", true, "d", true); 18. s.add("g"); 19. s.pollFirst(); 20. s.pollFirst(); 21. s.add("c2"); 22. System.out.println(s.size() +" "+ subs.size());
Which are true? (Choose all that apply.)
B and F are correct.
After "g" is added, TreeSet s contains six elements and TreeSet subs contains three (b, c, d), because "g" is out of the range of subs.
The first pollFirst()
finds and removes only the "a".
The second pollFirst()
finds and removes the "b" from both TreeSet objects.
The final add()
is in range of both TreeSets
.
The final contents are [c,c2,d,e,g] and [c,c2,d].