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 / punch
Their is NO need to override any methods of student class,
bcoz in the ket of hashmap we are using String and equal
method and hashcode method of String class is already
overrided . So NO need to override any methods and take help
of String class of the same.
| Is This Answer Correct ? | 1 Yes | 7 No |
Post New Answer View All Answers
Does java allow overriding static methods ?
Can we clone singleton class in java?
Is java util list serializable?
What are the main uses of this keyword?
Explain about static imports in java?
Difference between comparator and comparable in java?
what do you mean by classloader in java?
Explain a situation where finally block will not be executed?
enlist some features of jdk.
What is an object’s lock and which object’s have locks?
What is the difference amongst jvm spec, jvm implementation, jvm runtime ?
How to make a write-only class in java?
What is the difference between delete and delete[]
What are white spaces in java?
Which is best ide for java?