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
How to call one constructor from the other constructor ?
What is a super method?
What is array size in java?
Is passing by reference faster?
Explain runtime exceptions?
What is OOP Language?
What is the collections api in java programming?
What is hashmap in java?
What is a byte array?
What are 3 boolean operators?
What is a class component?
What is boolean flag in java?
Why can't we override private static methods?
Can we use a default constructor of a class even if an explicit constructor is defined?
What is the requirement of thread in java?