File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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

SCJP S&B self test question 7.16

Andrew Shumway

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:


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

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

"I'm not back." - Bill Harding, Twister
I agree. Here's the link:
subject: SCJP S&B self test question 7.16
jQuery in Action, 3rd edition