File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

generics

 
mohammad shaid
Ranch Hand
Posts: 86
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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???

 
Vijitha Kumara
Bartender
Posts: 3908
9
Chrome Fedora Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic