Home » JAVA Programming » Collections » Question
  1. What is the output of this program?
    import java.util.*;
    public class Map_Exmple
    {
    public static void main(String args[])
    {
    TreeMap object = new TreeMap();
    object.put("I", new Integer(9));
    object.put("L", new Integer(12));
    object.put("U", new Integer(21));
    System.out.println(object.entrySet());
    }
    }
    1. 9, 12, 21
    2. I, L, U
    3. [9, 12, 21]
    4. [I=9, L=12, U=21]
    5. None of these
Correct Option: D

object.entrySet() method is used to obtain a set that contains the entries in the map. This method provides set view of the invoking map.



Your comments will be displayed only after manual approval.