This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
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: 18671
This has now been anwered here. Sorry about that.


"I'm not back." - Bill Harding, Twister
 
 
subject: SCJP S&B self test question 7.16
 
Similar Threads
Problem with Generics
Generics Question
Doubt in Generics
Generics
About Chapter 7: Generics and Collections