Which is simplest and correct code snippet needs to be put in the main function to replace the value object of the HashMap for the key “orange”?

  1. itemMap.remove("orange"); itemMap.put("orange", new Item("Orange") );

  2. ((Item)itemMap.get(“orange”)).name = “Orange”;

  3. itemMap.put("orange", new Item("Orange") );

  4. None of above


Correct Option: B

Find more quizzes: