Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Write a program in java to calculate the difference between the sum of the odd level and even level nodes of a binary tree.

1068


Is int primitive data type?

954


What is the difference between superclass and subclass?

1181


How can we create a thread in java?

1031


How do you achieve singleton?

988


What is the difference between hashmap and hashtable? What is an interface?

1171


What is the difference between conversation & casting?

1060


Give example to differentiate between call by value and call by reference.

1065


What is an object's lock and which object's have locks in java programming?

1055


Who is the owner of java?

1005


What is the relationship difference the canvas class and the graphics class?

1062


What does string [] args mean?

1020


Which graphs are functions?

977


What are identifiers in java?

1133


What is a class in java?

1016