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

Can we override static methods in java?

1023


What is the use of inner class?

1000


What is a function argument in java?

952


What is the concept of multithreading?

933


Can a method inside a interface be declared as final?

957


What does sprintf mean?

886


How we can declare a static variable?

1072


What do you mean by checked exceptions?

907


Which data type is class in java?

963


What is the difference between super class & sub class?

1096


how to deploy apache tomcat server to weblogic server in java

2044


what invokes a threads run() method? : Java thread

969


How many classes can any class inherit java?

933


Is passing by reference faster?

949


How do you identify if jvm is 32-bit or 64-bit from java program?

916