Q7: Which declarations will compile without warnings?
Select the four correct answers.
(a) Map<Integer, Map<Integer,
String>> map1
= new HashMap<Integer, HashMap<Integer, String>>();
(b) Map<Integer, HashMap<Integer, String>> map2
= new HashMap<Integer, HashMap<Integer, String>>();***
(c) Map<Integer, Integer> map3 = new HashMap<Integer, Integer>();***
(d) Map<? super Integer, ? super Integer> map3
= new HashMap<? super Integer, ? super Integer>();
(e) Map<? super Integer, ? super Integer> map5 = new HashMap<Number, Number>();***
(f) Map<? extends Number, ? extends Number> map6
= new HashMap<Nmber, Number>();***WOULD WORK IF NMBER WAS "NUMBER"
(g) Map<?, ?> map7 = new HashMap<?, ?>();
This is a question i'm working on for a class that uses the
SCJP study guide.
The ones marked with asterisks all have unchecked warnings when plugged into some code while the other ones all have errors when plugging into some code.
So I do not know what answers would be right then. What is right and what is wrong?