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


Please Help Members By Posting Answers For Below Questions

Explain about fail safe iterators in java?

551


What is set and get methods in java?

528


What do you understand by private, protected and public?

504


what is static import in java? Explain

540


What does the ‘static’ keyword mean? Is it possible to override private or static method in java?

551






Can a class declared as private be accessed outside it’s package?

496


How does multithreading take place on a computer with a single cpu?

524


What is qms certification?

512


describe synchronization in respect to multithreading? : Java thread

485


Explain the difference between intermediate and terminal operations in java8?

549


What are latest features introduced with java 8?

574


Can long be null in java?

533


What is == in java?

552


define polymorphism in java

618


What is difference between fail-fast and fail-safe?

576