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.