P

Pradeep Sikarwar • 9.01K Points
Tutor III

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);
}

}
  • (A) 1
  • (B) 5 {null=null, 2=d, 7=c, 9=w, 11=a}
  • (C) Runtime exception
  • (D) Compile time exception
  • Correct Answer - Option(B)
  • Views: 112
  • Filed under category JAVA

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.


Question analytics