aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Generic Confusion Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Generic Confusion" Watch "Generic Confusion" New topic
Author

Generic Confusion

Prashant Kataria
Greenhorn

Joined: Sep 16, 2006
Posts: 3
public static <E extends Number> List<? super E> process(List<E> num)

this is the method's signature.
i want to use method like this
//Insert cod here
output=process(input);

which pair i should put at //Insert code here so that my code compile? at least is should accept input and output?

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

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

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

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

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

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

e. ArrayList<> input=null;
ArrayList<> output=null;

the answer in My book (SCJP 310-055 by Kathy Sierra and Bert Bates)
is b,e,f
but practically when i tested the code none of copiled.
please help to get answere
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
That's correct - it does not compile for any of the choices. Please see the K & B errata for the correction to the question.

K & B errata
[ September 16, 2006: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Prashant Kataria
Greenhorn

Joined: Sep 16, 2006
Posts: 3
Thnaks for help.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Generic Confusion
 
Similar Threads
Study Gude Chap 7 Q16 (errata applied)
doubt abt Generics mock question - from K&B
SCJP Chapter 7, Question #16
S&B 1.5 Chapter 7, question 16
generic, self test example