Multiple choice technology programming languages

What is the output for the below code ? import java.util.NavigableMap; import java.util.concurrent.ConcurrentSkipListMap; public class Test { public static void main(String... args) { NavigableMapnavMap = new ConcurrentSkipListMap(); navMap.put(4, "April"); navMap.put(5, "May"); navMap.put(6, "June"); navMap.put(1, "January"); navMap.put(2, "February"); System.out.print(navMap.floorKey(3)); } }

  1. Compile error : No method name like floorKey()

  2. null

  3. NullPointerException

  4. 2

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The floorKey(k) method returns the greatest key less than or equal to k. The map contains keys 1,2,4,5,6 (sorted order). floorKey(3) looks for the largest key <= 3, which is 2. The method exists in NavigableMap, so no compile error. The map has entries, so result is not null. Output is 2.