Question: hashCode() methods: public class Creature { Il note: age and name are considered significant fields of the Cre ature class private int age; private String

hashCode() methods: public class Creature \{ Il note: age and name are considered significant fields of the Cre ature class private int age; private String name; I* creature constructor \& getter methods for the above two fields elided ... * eOverride public int hashCode() \{ return Objects.hash(age, name); } @0verride public boolean equals(object o) \{ uals(..) if (0= null) { return false; }// as per the contract for eq re Creature oAsCreature =( Creature) 0;/1 downcast o to a Creatu e; } if (!this. name. equals(oAs(reature.getName())) \{ return fals if (this.age != oAsCreature.getAge()) \{ return false; } return true; 1/ this creature and the other creature ' O ' are t he same/equal 3 Identify from the following options any visible issue with the equals or hashCode method shown above. no issues with equals or hash Code here the equals method, before downcasting 0 , should use instanceof to verify o is a Creature object in the equals(..) method, the third if statement condition should say: !this.age.equals(oAsCreature.getAge()) in the equals(..) method, the second if statement condition should say: this.name != oAsCreature.getName()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
