This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 3817

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]
Don't get me started about those stupid light bulbs.
subject: generics
Similar Threads
commons file upload - how big file can it handle?
why dont i get an exception here?
how to turn javascript on
Fetching values from database and populating it in drop down and text fields
CertPal Question