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
Can we have try without catch block?
If try block is successfully executed, Then Is Finally block executed?
What is time complexity algorithm?
What if static is removed from main method?
What is array initialization in java?
Which variables are stored in stack?
Similarity and difference between static block and static method ?
Can we create our own daemon thread?
Which sorting is used in arrays sort in java?
Why put method is used?
Explain garbage collection in java?
Can variables be used in java without initialization?
What are the three types of design patterns?
What is the difference between yielding and sleeping in java programming?
Give differences between Quicksort &Mergesort. When should these sorts be used andwhat is their running time in java?