SCJP Module-9 Question-5


 

SCJP Module-9 Question-5

The Sample program given below will check your understanding of ConcurrentSkipListMap in Collection framework.

The Sample program given below will check your understanding of ConcurrentSkipListMap in Collection framework.

Given below the sample code :

import java.util.NavigableMap;
import java.util.concurrent.ConcurrentSkipListMap;
public class CheckSize {
public static void main(String... args) {
NavigableMap <Integer, String>nM = new ConcurrentSkipListMap<Integer, String>();
nM.put(4, "Wednesday");
nM.put(5, "Thursday");
nM.put(6, "Friday");
nM.put(1, "Sunday");
nM.put(2, "Monday");
System.out.print(nM.ceilingKey(3));
}}

What will be the output of the above ?

1. Compile error

2. 2

3. null

4. 4

Answer

(4)

Explanation

ceilingKey() : Returns the least key greater than or equal to the given key, or null if there is no such key.

Ads