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
What is the function of log?
What are the advantages of java?
What are inbuilt functions in java?
Why constructor has no return type?
Does java have a compiler?
What is are packages?
What is a jagged array in java?
What is the difference between public, private, protected, and friend access?
What is static in java?
Why Set interface contains unique elements, what internally implemented for this so that it contains unique elements?
Which is better stringbuffer or stringbuilder?
Explain spliterator in java8?
How to split arraylist elements in java?
What is return in java?
What are the access modifiers in java?