Answer: dog
null
pet
Explanation:
taking into condiserations the various animals and their tag given to them;
OUTPUT :
dog
null
pet
PROOF:
Where the Initially map : {}
after map.put('D', "dog"), map : {'D':"dog"}
after map.put('P', "pig"), map : {'D':"dog", 'P':"pig"}
after map.put('C', "cat"), map : {'D':"dog", 'P':"pig", 'C':"cat"}
after map.put('P', "pet"), map : {'D':"dog", 'P':"pet", 'C':"cat"}, what this does is replace the value of P with "pet"
map.get('D') prints dog.
map.get('E') prints null, key is not present
map.get('P') prints pet
cheers I hope this helped !!