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

Can we clone singleton object?

569


What is the use of static methods?

595


Tell me the latest versions in java related areas?

587


Is 64bit faster than 32 bit?

584


State differences between C and Java?

669






List out five keywords related to exception handling ?

605


Can we declare a class as static?

598


What are the differences between path and classpath variables?

505


What is array in java?

537


Why you should not use singleton?

548


How to disable caching on back button of the browser?

531


What is the difference between yielding and sleeping?

564


5 Coding best practices you learned in java?

640


Where are the card layouts used?

616


What is a stringbuilder?

515