kaushal rathore

Greenhorn
+ Follow
since Jul 29, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by kaushal rathore

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?