... and yes, random() should not be used (Whizlabs also mentioned this). And they also said that if array is used in equals(), then
you should implement the hashCode() that include all the elements of the array (exclude the null value in the array).
And here is one of the questions regarding this topic:
Which of the following statements are true:
a) if a and b are two StringBuffer references, and a.hashCode() == b.hashCode() is true, then a.equals(b) will also be true
b) if a and b are two Byte references and a==b is true, then a.equals(b) will also be true
c) A class SomeClass has two variables, x and y. The overridden equals() method uses both these variables for the rquals comparison, but the hashCode() method may choose to use only one of them
d) If a is an Integer reference, and b is a Float reference, then a.equals(b) will result in an exception being thrown at runtime
e) Only choice A is correct
The answer is B and C.
What I am interested is option C. They explain that the hashCode() method may contain all or subset of the variables used in the equals comparison but it should not contain the variables, which are not used for the equals comparison. Since I cannot find such information in K&B book, I am not sure whether this type of question will be appeared in the exam.