Question: A) If you write a class named Gamma, but do not override the equals method, Gamma will still be inheriting an equals method from the
A) If you write a class named Gamma, but do not override the equals method, Gamma will still be inheriting an equalsmethod from the Object class. What is the default behavior of the equals method? (When will two Gamma objects be considered equal if they are inserted into a hash table?) Briefly explain your answer.
B) Consider class Gamma again. It will also inherit a hashCode method from the Object class. What is the default behavior of the hashCode method? Briefly explain your answer.
C) When you write a class, if you override the equals method, you must also override hashCode. If you don't, your objects probably won't work in hash tables. Show this with a simple example. (Explain why a hash table might fail when using objects that override equals, but not hashCode.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
