In this article, I am revisiting couple of interesting question related to internal working of HashMap in Java, mostly asked to senior Java developers, ranging from 4 to 6 and upto 8 years of experience. I did cover lot of these questions from HashMap, ranging from thread-safety to race conditions, in my post about internal working of Java HashMap, but I thought to revisit two of those questions, How get method of HashMap or Hashtable works internally in Java and What happens if two different keys return same hashCode, how do you return value form HashMap in that case. These are the question, which is highly popular in investment banking domain, and preferred choice of interviewer, while interviewing experienced Java professional. If these questions are still being asked, it means not many are answering them in the clarity and confidence they are looking for. This motivates me to revisit these questions again. On a side note, in order to understand these questions, you should have good knowledge of equals and hashcode method as well. At least you should know that :
1) Two unequal object may return same hashcode.
2) When two objects are equal by equals(), they must have same hashcode.