Mili Dua wrote: IS THERE ANY POSSIBILITY THAT or i should say that whether it can happen that the two objects are unequal but calling the hashcode() method on each of them must produce the same integer result ??
Is there a possibility that two objects are unequal but calling hashCode produces the same integer result? Yes, if the hashCode method is not properly overridden.
Are there any scenarios where it should be like this? No. This kind of hashCode implementation is an inefficient one. Legal, but inefficient.
To avoid scenarios like these, the same instance variables used in overridden equals method are used in the overridden hashCode method. And static and transient variables are not supposed to be used.