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
Why 1 is not a prime number?
Write a program to check string is palindrome without using loop?
What is sorting algorithm in java?
What’s the difference between applets and standalone program?
What is a functional interface?
When should you make a function static?
What is JDBC Driver interface?How can you retrieve data from the ResultSet
What is a hashmap used for?
Explain constructors and types of constructors in java.
What is the function of java?
What is the difference between a break statement and a continue statement?
Explain how to convert any java object into byte array.
Why does java not support pointers?
What does pointer mean?
What is immutable in java?