File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes SCJP S&B self test question 7.16 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "SCJP S&B self test question 7.16" Watch "SCJP S&B self test question 7.16" New topic
Author

SCJP S&B self test question 7.16

Andrew Shumway
Greenhorn

Joined: Jan 05, 2006
Posts: 18
I've got a question about problem 16 in the self test exam for chapter 7 (Generics and Collections) in the Siera and Bates SCJP programmer for java 5 study guide.

The question reads

Given a method declared as:


A programmer wants to use this method like this:




The answer key lists the following as legal:


AND


Now, I'm not claiming to know everying about the <? super E> type parameters in the question but I'm a bit stumped. It would seem that the return type could be any List with parameter Type of E or a super of E. However the following is in the list of answers that are wrong.



So, to clear up the confusion I tried compiling the following:

The compiler complains about the call output = process(input); with the following error


This indicates that I'm wrong about the parameter type of the returned list and that it can not be a supertype of E. However... If you change the comments in the code so that you are using Case 1 the compiler gives the same error.

Any ideas

-- andrew
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18670
This has now been anwered here. Sorry about that.


"I'm not back." - Bill Harding, Twister
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: SCJP S&B self test question 7.16
 
Similar Threads
About Chapter 7: Generics and Collections
Doubt in Generics
Generics Question
Problem with Generics
Generics