aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt-MasterExam-Hashcode 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-MasterExam-Hashcode" Watch "Doubt-MasterExam-Hashcode" New topic
Author

Doubt-MasterExam-Hashcode

Richa Sharma
Ranch Hand

Joined: Dec 06, 2008
Posts: 47
Hi Guys


Please see the masterExam question.






The correct anwer is C and D.

C) return ((SortOf)o).code.length()*((SortOf)o).bal==this.code.length()*this.bal;
D) return ((SortOf)o).code.length()*((SortOf)o).bal*((SortOf)o).rate==this.code.length()*this.bal*this.rate;


Why is choice D correct?




For unequal hashcodes this choice might return equals as true?



Thanks
Richa
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19066
    
  40


For future reference, it may be a good idea to...

1. Not have to download a 700k picture, just to have 5 lines of code. Heck, even retyping it would have made it easier on everyone.

2. Do a search first before asking a question. A quick search shows that this question has been asked many times. Here is the first link...

http://www.coderanch.com/t/458689/Programmer-Certification-SCJP/certification/Possible-Wrong-answer-k-b

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Richa Sharma
Ranch Hand

Joined: Dec 06, 2008
Posts: 47
Thanks Henry

I will be careful in the future.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt-MasterExam-Hashcode