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 is meant by object oriented programming – oop?

759


What is the purpose class.forname method?

749


What languages are pass by reference?

783


Define locale.

812


What are the advantages of exception handling?

801


What is string [] java?

738


Why collection doesn’t extend cloneable and serializable interfaces?

880


Can we convert list to set in java?

734


Are functions objects in java?

804


What is the base class of all classes?

764


What two classes are used to read data only?

851


Is Java a dying language?

813


What is difference between local variable and global variable?

712


What is jar?

849


How can we run a java program without making any object?

768