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 class members by default?
What is the purpose of interface?
What is the difference between char and char *?
Explain the meaning of java applet.
Which language is java?
Which programming language is most secure?
What is passing parameters in java?
What are the differences between abstract class and interface?
What is Gang of four design patterns
What’s the difference between constructors and other methods?
Which method you will use to create a new file to store some log data. Each time a new log entry is necessary, write string to the file in java ?
Why java strings are immutable in nature?
Explain the importance of thread scheduler in java?
what are three ways in which a thread can enter the waiting state? Or what are different ways in which a thread can enter the waiting state? : Java thread
What is the difference between a checked and an unchecked exception?