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
How do you input a string in java?
What are the legal operands of the instanceof operator?
Write a program in java to find the maximum and minimum value node from a circular linked list.
Name four container classes.
what methods would you overwrite in java.lang.object class?
How do you identify independent and dependent variables?
What is string manipulation?
What is data movement?
What is null mean in java?
What is the generic function?
Can private method static?
What are local variables?
What are constants and how to create constants in java?
How many types of methods are there in java?
what is function overloading in java?