This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt-MasterExam-Hashcode

 
Richa Sharma
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 20880
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Richa Sharma
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Henry

I will be careful in the future.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic