I've got a question about problem 16 in the self test exam for chapter 7 (Generics and Collections) in the Siera and Bates SCJP programmer for java 5 study guide.
The question reads
Given a method declared as:
A programmer wants to use this method like this:
The answer key lists the following as legal:
AND
Now, I'm not claiming to know everying about the <? super E> type parameters in the question but I'm a bit stumped. It would seem that the return type could be any List with parameter Type of E or a super of E. However the following is in the list of answers that are wrong.
So, to clear up the confusion I tried compiling the following:
The compiler complains about the call output = process(input); with the following error
This indicates that I'm wrong about the parameter type of the returned list and that it can not be a supertype of E. However... If you change the comments in the code so that you are using Case 1 the compiler gives the same error.