Home Tutorial Java Scjp Part9 SCJP Module-9 Question-6

 
 

Share on Google+Share on Google+
SCJP Module-9 Question-6
Posted on: July 16, 2010 at 12:00 AM
Advertisement
The example given below will test your knowledge of ConcurrentSkipListMap and you will learn how to get the current last value inserted using the getFloorKey() method of ConcurrentSkipListMap.

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.floorKey(3));
}}

What will be the output of the above code ?

1. Compile error

2. 2

3. null

4. 4

Answer

(2)

Explanation

floorKey()  : Returns the greatest key less than or equal to the given key, or null if there is no such key.

Advertisement

Related Tags for SCJP Module-9 Question-6:


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.

Posted on: July 16, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com