Below is a question from Kathy & Bert Bates SCJP 5 preparation CD. I have posted this elsewhere too, but have not gotten a satisfactory explanation until now.... Please help me understand this:
public class BackLister {
//Insert code here
{
List<T> output=new LinkedList<T>();
for(T t:input)
output.add(0,t);
return output;
}
}
Which of the following can be inserted at //Insert code here
?
- A.
public static <T> List<T> backwards(List<T> input)
- B.
public static <T> List<T> backwards(List<? extends T> input)
- C.
public static <T> List<T> backwards(List<? super T> input)
- D.
public static <T> List<? extends T> backwards(List<T> input)
- E.
public static <T> List<? super T> backwards(List<T> input)
- F.
public static <? extends T> List<T> backwards(List<T> input)
I understand that A and B are correct; however, not why are D and E also right. I can see that C and F are also incorrect. Can someone please tell me why D and E are correct.