This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Jay Shukla wrote:1. It is the mapping of memory address of an object to an integer value.
No, forget about this, it does not have anything to do with the memory address of an object, and it's not important to know this.
The API documentation of the method java.lang.Object.hashCode() says:
API documentation wrote:As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)
But this is just an implementation detail, it is not a requirement, and the implementation might be different in reality. If you override hashCode(), you will typically not do anything with the memory address of the object; it's not even possible to get the memory address of an object in pure Java.
Christophe Verré wrote: . . . It's the one listed in our JavaBeginnersFaq.
Yes, that was the old edition. It used to be possible to download a PDF of chapter 3 as a sample chapter, but they have changed the link and it now directs to the front page of an Oracle Java Developers website.