More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know.
Q4. There is a Table Student having Student Id, Name and Total Marks. Can you please write an SQL that will display the maximum marks obtained by a student ?
Ans. The impact of both cases (fixed hashcode or random hashcode for keys) will have same result and that is "unexpected behavior". The very basic need of hashcode in HashMap is to identify the bucket location where to put the key-value pair, and from where it has to be retrieved.
If the hashcode of key object changes every time, the exact location of key-value pair will be calculated different, every time. This way, one object stored in HashMap will be lost forever and there will be very minimum possibility to get it back from map.
For this same reason, key are suggested to be immutable, so that they return a unique and same hashcode each time requested on same key object.
Help us improve. Please let us know the company, where you were asked this question :