文档介绍:1. Given the following,
11. x = 0;
12. if (() != () ) x = x + 1;
13. if ((x4) ) x = x + 10;
14. if (!(x6) ) x = x + 100;
15. if (() == () ) x = x + 1000;
16. ("x = " + x);
and assuming that the equals () and hashCode() methods are property implemented, if the output is “x = 1111”, which of the following statements will always be true?
A. (x1)
B. () == ()
C. () != ()
D. (x7)
2. Given the following,
class Test1 {
public int value;
public int hashCode() { return 42; }
}
class Test2 {
public int value;
public int hashcode() { return (int)(value^5); }
}
which statement is true?
A. class Test1 will pile.
B. The Test1 hashCode() method is more efficient than the Test2 hashCode() method.
C. The Test1 hashCode() method is less efficient than the Test2 hashCode() method.
D. class Test2 will pile.
E. The two hashcode() methods will have the same efficiency.
3. Which two statements are true paring two instances of the same class, given that the equals() and hashCode() methods have been properly overridden? (Choose two.)
A. If the equals() method returns true, the hashCode() comparison == must
return true.
B. If the equals() method returns false, the hashCode() comparison != must return
true.
C. If the hashCode() compar