This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt in K&B - Generics & Collections - Question 8 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 "Doubt in K&B - Generics & Collections - Question 8" Watch "Doubt in K&B - Generics & Collections - Question 8" New topic
Author

Doubt in K&B - Generics & Collections - Question 8

Jeff Schuler
Greenhorn

Joined: Apr 17, 2007
Posts: 23
In the K&B book for chapter 7, question 8, it says that 'E' is one of the correct responses. When I keyed it in (and added a main method), it gave a compiler error due to incompatible types. I put asterisks around the lines in question. Can someone explain to me why it is considered a valid option?



[ July 02, 2007: Message edited by: Jeff Schuler ]
Remko Strating
Ranch Hand

Joined: Dec 28, 2006
Posts: 893
Option E is valid. You have forgotten something in your code

Your line 17 should be



If not you have a compiler error incompatible types, because the HashMap is returning an object and not an Integer.


Remko (My website)
SCJP 1.5, SCWCD 1.4, SCDJWS 1.4, SCBCD 1.5, ITIL(Manager), Prince2(Practitioner), Reading/ gaining experience for SCEA,
Manfred Klug
Ranch Hand

Joined: Jun 04, 2007
Posts: 377
Originally posted by Jeff Schuler:
In the K&B book for chapter 7, question 8, it says that 'E' is one of the correct responses.
You must apply all of the changes.
Jeff Schuler
Greenhorn

Joined: Apr 17, 2007
Posts: 23
Originally posted by Manfred Klug:
You must apply all of the changes.


Ok. I was treating each change independently. So the question is asking if all generic changes were made, which ones would be valid.

Thanks.
Jeff Schuler
Greenhorn

Joined: Apr 17, 2007
Posts: 23
Originally posted by Remko Strating:
Option E is valid. You have forgotten something in your code

Your line 17 should be



If not you have a compiler error incompatible types, because the HashMap is returning an object and not an Integer.


Option E doesn't have the Integer casted. It turns out I misunderstood the question though.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in K&B - Generics & Collections - Question 8