A

Admin • 825.56K Points
Coach

Q. What will be the output of given code

Code:
import java.util.HashMap;
import java.util.Map;

public class MyClass
{
public static void main(String args[])
{
Map<String,String> hashMap = new HashMap<String,String>();
hashMap.put(new String(“a”),”audi”);
hashMap.put(new String(“a”),”ferrari”);
System.out.println(hashMap);
}
}
  • (A) Runtime exception
  • (B) [1]
  • (C) [null, 1]
  • (D) {a=ferrari}
  • Correct Answer - Option(D)
  • Views: 7
  • Filed under category Java
  • Hashtags:

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.