About Question enthuware.ocpjp.v7.2.1302 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
aspire_jp
Posts: 8
Joined: Wed Apr 17, 2013 12:37 pm
Contact:

About Question enthuware.ocpjp.v7.2.1302 :

Post by aspire_jp »

Hey,
If we use TreeMap the Book must be Comparable. But as nothing of this sort is mentioned the 2nd option //replace line 1 may not be correct.
Thanks!

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1302 :

Post by admin »

Since the code for Book class is not given, you have to assume that it is compatible with options that are otherwise valid. It is not possible to specify everything in the problem statement and reasonable assumptions have to be made. For example, the Book class should also implement hashCode and equals sensibly but that is also not given in the questions. In that case all the options would be invalid!

HTH,
Paul.

laura90_m@yahoo.com
Posts: 3
Joined: Sun Apr 14, 2013 12:02 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1302 :

Post by laura90_m@yahoo.com »

An option is represented by

Code: Select all

Replace line //4 and //5 with:
Integer i = map.get(b); 
return i == null? 0:i;
But the explanation says that
This change is fine but it is not required because it has nothing to do with generics.
Yes, there is no need to change //4 and //5, because the generics also support the old code. But I would say that the change IS related to generics, because the cast was removed, and this happened because generics is used.

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1302 :

Post by admin »

I see your point, Laura. The explanation has been modified accordingly.

thank you for your feedback!
Paul.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 2 guests