Search Interview Questions | ![]() ![]() Click here and help us by providing the answer. ![]() Click Correct / Improve and please let us know. |
|
| ||||
Interview Questions and Answers | ||||
| ||||
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. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() or What is the difference between String , StringBuilder and StringBuffer ? | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() or Explain OOPs Principles or Explain OOPs Concepts or Explain OOPs features or Tell me something about OOPs | ||||
![]() | ||||
![]() | ||||