jQuery in Action, 3rd edition
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes generics 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 "generics" Watch "generics" New topic


mohammad shaid
Ranch Hand

Joined: May 05, 2010
Posts: 86
Scjp Mock --CertPal click on link

Given this code fragment what can be added to the list ?
Assume that Toll is an empty class and all imports have been made

2 options are correct--
--The answers are toll can be added and
--the subclass of toll can be added..

but the second option is wrong according to me
superclass of toll can be added must be the 2nd option;;

am i right???

Thanks & Regards,
Vijitha Kumara

Joined: Mar 24, 2008
Posts: 3902

You can add instances of "Toll" or any subtypes of it in to the list. What "<? super Toll>" in the reference declaration says that the type of the actual List would be of "Toll" or anything above that.

[How to ask questions] [Twitter]
I agree. Here's the link: http://aspose.com/file-tools
subject: generics
It's not a secret anymore!