A
Q. What will be the output of the following code –
Code:
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public class MyClass
{
public static void main(String args[])
{
Map<Integer,String> hashMap = new HashMap<Integer,String>();
hashMap.put(11,”a”);
Collections.unmodifiableMap(hashMap);
hashMap.put(12,”b”);
System.out.println(hashMap);
}
}
import java.util.HashMap;
import java.util.Map;
public class MyClass
{
public static void main(String args[])
{
Map<Integer,String> hashMap = new HashMap<Integer,String>();
hashMap.put(11,”a”);
Collections.unmodifiableMap(hashMap);
hashMap.put(12,”b”);
System.out.println(hashMap);
}
}
- Correct Answer - Option(B)
- Views: 9
- Filed under category Java
- Hashtags:
Discusssion
Login to discuss.