Hash codes are not "assigned" to objects.
If your question is about how the default implementation of the hashCode() method works, in class Object, then the answer is that it's not specified how this works, and you don't need to know.
However, the API documentation of Object.hashCode() says:
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 you'd better forget again immediately that hash codes have anything to do with the memory address of objects, because it's not necessarily true, and it's not even useful to know that.
It's much more useful to understand what the purpose of hash codes is and what they are used for in
Java than to know the particular implementation details of Object.hashCode().