Welcome Guest | Sign in | Register
Objects and Collections - Discussion Page For Q.2909 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Objects and Collections > Questions and Answers

Exercise:

Section 1

Q: What two statements are true about properly overridden hashCode() andequals() methods?

1. hashCode() doesn't have to be overridden if equals() is.
2. equals() doesn't have to be overridden if hashCode() is.
3. hashCode() can always return the same value, regardless of the object that invoked it.
4. equals() can be true even if it's comparing different objects.
A. 1 and 2 B. 2 and 3
C. 3 and 4 D. 1 and 3

Answer and Explanation

Answer:3 and 4

Explanation:
(3) and (4) are correct.
(1) and (2) are incorrect because by contract hashCode() and equals() can't be overridden unless both are overridden.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.