wood burning stoves 2.0*
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 Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "generics" Watch "generics" New topic
Author

generics

mohammad shaid
Ranch Hand

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

http://www.certpal.com/ExamWeb/content/questionLoader.do?offeringID=6&attempt=0&examid=1&actionType=loadfinished&offeringType=0
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,
shaad
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3838

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.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: generics