Share on Google+Share on Google+

SCJP Module-9 Question-4

Advertisement
The program given below will check your understanding of NavigableMap, ConcurrentSkipListMap and how the ConcurrentSkipListMap is object is created.

Given below the sample code :

import java.util.NavigableMap;
import java.util.concurrent.ConcurrentSkipListMap;
public class Check {
public static void main(String... args) {
NavigableMap <Integer, String>nM = new ConcurrentSkipListMap<Integer, String>();
System.out.print(nM.lastEntry());
}
}

What will be the output of the code ?

1. Compile error

2. It throws exception

3. null

4. 0

Answer

(3)

Explanation

lastEntry()   Returns a key-value mapping associated with the greatest key in this map, or null if
the map is empty.

Advertisements

Posted on: July 16, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.