Menu
Topics Index
...
`

GetKey


If you need explanation Read this topic

If you need Answer Take test on this topic

GetKey
What will be the output of the following program?
import java.util.*;
public class GetKey {
    public static void main(String args[]) {
        NavigableMap<Integer, String> plr = new TreeMap<Integer, String>();
        plr.put(100, "Sachin");
        plr.put(90, "Dravid");
        plr.put(91, "Yuvraj");
        Integer it = plr.floorKey(89);
        System.out.print(it);
    }
}

A. 90
B. 100
C. 91
D. null
E. Compilation Error or Runtime Error
Topic: TreeMap In Java - java.util.TreeMap

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

D
Although floorkey represents it values to be floored i.e to a level down since there is no "89" it returns to null

Posted by Bhalkiker Badrinath    2014-01-30 04:16:48


E coz wen there is no represented value that is there is no 89 so returns an error

Posted by Lavanya Kategaru    2014-01-30 10:03:33


ans-D

Posted by Kick Bhasha    2014-01-30 12:09:05


Congratulations Bhalkiker Badrinath. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-01-31 05:37:12


© meritcampus 2019

All Rights Reserved.

Open In App