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

object.get(“L”) method is used to obtain the value associated with key “L”, which is 12.



Your comments will be displayed only after manual approval.