This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes generic problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "generic problem" Watch "generic problem" New topic
Author

generic problem

Kathy Juyao
Greenhorn

Joined: Sep 29, 2007
Posts: 1
I have question on K&B book Chapter7 Q16, see below.

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.)

ArrayList<Integer> input = null;

ArrayList<Integer> output = null;

ArrayList<Integer> input = null;

List<Integer> output = null;

ArrayList<Integer> input = null;

List<Number> output = null;

List<Number> input = null;

ArrayList<Integer> output = null;

List<Number> input = null;

List<Number> output
adam Lui
Ranch Hand

Joined: Sep 03, 2007
Posts: 186
public static <E extends Number> List<? super E> process(List<E> nums)


look at the errata for the K&B book. there is a typo here.
http://www.coderanch.com/t/257589/java-programmer-SCJP/certification/SCJP-Errata-Updated


it should be
public static <E extends Number> List<E> process(List<E> nums)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: generic problem