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}
πŸ’¬ Discuss
βœ… Correct Answer: (D) {a=ferrari}

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
281
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Tina Singh
Publisher
πŸ“ˆ
93%
Success Rate