xitiz bhatia

Greenhorn
+ Follow
since Nov 15, 2006
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 xitiz bhatia

K&B have mentioned the method declaration as erronous in their errata at the link below--
https://coderanch.com/t/257589/java-programmer-SCJP/certification/SCJP-Errata-Updated

Now the method declaration becomes-
public static <E extends Number> List<E> process(List<E> nums)

(C) is wrong because of the reason given in book.
[ November 15, 2006: Message edited by: xitiz bhatia ]
Daniel,
Regarding your reply to q16 from K&B posted in this thread..I am including the question for reference.
-----------------------
Question 16:

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? (Choose all that apply.)

A. ArrayList<Integer> input = null;
ArrayList<Integer> output = null;

B. ArrayList<Integer> input = null;
List<Integer> output = null;

C. ArrayList<Integer> input = null;
List<Number> output = null;

D. List<Number> input = null;
ArrayList<Integer> output = null;

E. List<Number> input = null;
List<Number> output = null;

F. List<Integer> input = null;
List<Integer> output = null;

G. None of the above.

-----------------------
According to book (A) and (D) are wrong because the return type of process is definitely declared as a List, not an ArrayList.
But why is (C) wrong??

why is (G) the answer according to you?

Xitiz
[ November 15, 2006: Message edited by: xitiz bhatia ]