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
Write a program in java to calculate the difference between the sum of the odd level and even level nodes of a binary tree.
Is int primitive data type?
What is the difference between superclass and subclass?
How can we create a thread in java?
How do you achieve singleton?
What is the difference between hashmap and hashtable? What is an interface?
What is the difference between conversation & casting?
Give example to differentiate between call by value and call by reference.
What is an object's lock and which object's have locks in java programming?
Who is the owner of java?
What is the relationship difference the canvas class and the graphics class?
What does string [] args mean?
Which graphs are functions?
What are identifiers in java?
What is a class in java?