7) Suppose there is Student class like
class student {
int age;
string name;
}
We want to store these objects in a HashMap. Do we need to
override any methods in Student class? If any which ones
and why? what if i just override equals or just hashcode?
what will be the results in both the cases?
Answer Posted / krishna
There is no need to override equals() and hashCode() methods. But if we want to eliminate duplicate objects in the HashMap, you should override both the methods. Either one is not enough.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What are memory tables?
Why is it called buffering?
What is the difference in between cpp and java? Can u explain in detail?
What’s the difference between the methods sleep() and wait()?
How can you share data between two thread in Java?
What happens when I use / and % with a negative numerator?
What does the “final” keyword mean in front of a variable? A method? A class?
Why collection doesn’t extend cloneable and serializable interfaces?
What is break and continue statement?
What is private static class in java?
What is a nested class?
Explain covariant method overriding in java.
What is constant in programming?
What are the three parts of a lambda expression?
Is java type safe?