jQuery in Action, 3rd edition
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes K & B book question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "K & B book question" Watch "K & B book question" New topic

K & B book question

Bing Qiao

Joined: Oct 24, 2006
Posts: 21
Page 634, a16

public static <E extends Number> List<? super E> process(List<E> nums)

A programmer wants to use this method like this:

Which pairs of declarations could be used for successful compilation?

C. ....

C is wrong because the return type evaluates to List<Integer>, and that can't be assigned to a variable of type List<Number>.

The book is obviously correct saying that C won't compile.
But I thought List<? super E> meant both E and E's supertypes could be returned. Why must the return type evaluate to List<Integer> then?

Many thanks!
[ October 26, 2006: Message edited by: Bing Qiao ]
Naveen Zed
Ranch Hand

Joined: Aug 11, 2006
Posts: 61
This was in the erraa list of K&B.so the changed thing is
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2398
I think this may be in the errata.
Venkat Sidh
Ranch Hand

Joined: Sep 30, 2006
Posts: 61

You mean C is also correct answer based on Errata.
Bing Qiao

Joined: Oct 24, 2006
Posts: 21
Sorry, but this is not in the Errata.
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
It is in this list.
I agree. Here's the link: http://aspose.com/file-tools
subject: K & B book question
It's not a secret anymore!