Q. What will be the output of the following code
Code:
import java.util.HashMap;
import java.util.Map;
public class HashMapTest {
public static void main(String args[])
{
Map<Integer,String> hashMap=new HashMap<Integer,String>();
hashMap.put(11,”animesh”);
hashMap.put(2,”ayushi”);
hashMap.put(7,”renuka”);
hashMap.put(9,”shivashish”);
hashMap.put(null,”null”);
System.out.println(hashMap.size());
System.out.println(hashMap);
}
}
β
Correct Answer: (B)
5 {null=null, 2=d, 7=c, 9=w, 11=a}