jQuery in Action, 3rd edition
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


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?

Henry Wong

Joined: Sep 28, 2004
Posts: 20531

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...



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
jQuery in Action, 3rd edition