In one of the mock exams it is given that the statement "The Hashcode method in the String class is the one inherited from class object" as incorrect. But it is right ?Am I right? Veena
SCJP1.4
"Continuous effort - not strength or intelligence - is the key to unlocking our potential."
*Winston Churchill
I think what is meant is, that the hashcode method is overridden in String. Offcourse Object has the hashcode method but that wouldn't calculate a proper hashcode for a String object. By overriding it one can say that String takes care of his own hashcode and is not depending on Object for it, other than that object declares it in the interface of Object and therefore all subclasses. Hope this helps?
The statement is correct. The String class implements both the equals method and the hashcode method. I'm too lazy to look it up right now, I think it is just a return 0 or something like that. In fact all the wrapper objects override those 2 methods
You mean the answer given in the mock exam is wrong right?This question was from Bill Brodgen's exam simulation applet.I scored 26/43 .Please anybody correct this.Coz these kinda questions make me postpone my decision to schedule exam. Thanks Veena
SCJP1.4
"Continuous effort - not strength or intelligence - is the key to unlocking our potential."
*Winston Churchill