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
Can we override static methods in java?
What is the use of inner class?
What is a function argument in java?
What is the concept of multithreading?
Can a method inside a interface be declared as final?
What does sprintf mean?
How we can declare a static variable?
What do you mean by checked exceptions?
Which data type is class in java?
What is the difference between super class & sub class?
how to deploy apache tomcat server to weblogic server in java
what invokes a threads run() method? : Java thread
How many classes can any class inherit java?
Is passing by reference faster?
How do you identify if jvm is 32-bit or 64-bit from java program?