Given a method declared as:
public static <E extends Number> List<? super E> process(List<E> nums)
A programmer wants to use this method like this:
// INSERT DECLARATIONS HERE
output = process(input);
Which pairs of declarations could be placed at // INSERT DECLARATIONS HERE to allow the code to compile?
The correct answers are:
B. ArrayList<Integer> input = null;
List<Integer> output = null;
E. List<Number> input = null;
List<Number> output = null;
F. List<Integer> input = null;
List<Integer> output = null;
Doubt:
we can assign List<E> type to List<? super E> type
but can we assign conversly List<? super E> to List<E> as we are doing in above example because the method "process" is returning List<? super E> and in correct answers we are assigninig this returning value "List<? super E>" to a "List<E> output" refrence?