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

What are the application of stack?

703


What is a java string?

754


How does arraylist size increase in java?

802


How to add menushortcut to menu item?

768


Can a constructor be private and how are this() and super() method used with constructor?

762


what are the high-level thread states? : Java thread

794


Should you use singleton pattern?

735


What are controls and their different types in awt?

868


What is the difference between a method and a function in alice?

836


why Interface used?

762


Differentiate jar and war files?

803


what is the difference between a threads start() and run() methods? : Java thread

790


How many types of interfaces are there?

791


Why do we use variables?

741


Why pass by reference is not possible in java?

745