A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Refactoring for Software Design Smells: Managing Technical Debt
this week in the
OO, Patterns, UML and Refactoring
Programmer Certification (SCJP/OCPJP)
Joined: May 05, 2010
May 23, 2010 07:31:03
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
List <? super Toll> list = new ArrayList<Toll>();
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,
Joined: Mar 24, 2008
May 23, 2010 08:19:51
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
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
why dont i get an exception here?
commons file upload - how big file can it handle?
Fetching values from database and populating it in drop down and text fields
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015