• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

SCJP S&B self test question 7.16  RSS feed

Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has now been anwered here. Sorry about that.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!