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

What are memory tables?

1152


Why is it called buffering?

1186


What is the difference in between cpp and java? Can u explain in detail?

1158


What’s the difference between the methods sleep() and wait()?

1069


How can you share data between two thread in Java?

988


What happens when I use / and % with a negative numerator?

1083


What does the “final” keyword mean in front of a variable? A method? A class?

1038


Why collection doesn’t extend cloneable and serializable interfaces?

1151


What is break and continue statement?

1170


What is private static class in java?

1064


What is a nested class?

1177


Explain covariant method overriding in java.

1168


What is constant in programming?

1182


What are the three parts of a lambda expression?

1063


Is java type safe?

1007