Given:
3. import java.util.*; 4. public class Main { 5. public static void main(String[] args) { 6. TreeMap<String, String> myMap = new TreeMap<String, String>(); 7. myMap.put("a", "apple"); myMap.put("d", "date"); 8. myMap.put("f", "fig"); myMap.put("p", "pear"); 9. System.out.println("1st here: " + // sop 1 10. myMap.higherKey("f")); 11. System.out.println("1st here: " + // sop 2 12. myMap.ceilingKey("f")); 13. System.out.println("1st here: " + // sop 3 14. myMap.floorKey("f")); 15. SortedMap<String, String> sub = new TreeMap<String, String>(); 16. sub = myMap.tailMap("f"); 17. System.out.println("1st here: " + // sop 4 18. sub.firstKey());/*from w w w.ja va 2s. c o m*/ 19. } 20. }
Which of the System.out.println statements will produce the output 1st here: p?
Choose all that apply.
A is correct.
The ceilingKey()
method's argument is inclusive.
The floorKey()
method would be used to find keys before the specified key.
The firstKey()
method's argument is also inclusive.