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 class members by default?

1077


What is the purpose of interface?

996


What is the difference between char and char *?

1071


Explain the meaning of java applet.

1063


Which language is java?

971


Which programming language is most secure?

985


What is passing parameters in java?

1032


What are the differences between abstract class and interface?

1061


What is Gang of four design patterns

1051


What’s the difference between constructors and other methods?

988


Which method you will use to create a new file to store some log data. Each time a new log entry is necessary, write string to the file in java ?

1152


Why java strings are immutable in nature?

1053


Explain the importance of thread scheduler in java?

1001


what are three ways in which a thread can enter the waiting state? Or what are different ways in which a thread can enter the waiting state? : Java thread

962


What is the difference between a checked and an unchecked exception?

984