πŸ“Š JAVA
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
πŸ’¬ Discuss
βœ… Correct Answer: (B) 5 {null=null, 2=d, 7=c, 9=w, 11=a}

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
168
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Pradeep Sikarwar
Publisher
πŸ“ˆ
86%
Success Rate