adplus-dvertising
frame-decoration

Question

What two statements are true about properly overridden hashCode() and equals() 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

Posted under Java Programming

Answer: (c).3 and 4

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What two statements are true about properly overridden hashCode() and equals() methods? 1. hashCode() doesn't have to be overridden if equals() is. 2. equals() doesn't have to...

Similar Questions

Discover Related MCQs

Q. Which two statements are true about comparing two instances of the same class, given that the equals() and hashCode() methods have been properly overridden?

1. If the equals() method returns true, the hashCode() comparison == must return true.
2. If the equals() method returns false, the hashCode() comparison != must return true.
3. If the hashCode() comparison == returns true, the equals() method must return true.
4.If the hashCode() comparison == returns true, the equals() method might return true.

Q. Which of the following is smallest integer data type ?

Q. Which of the following is not a primitive data type ?

Q. Integer Data type does not include following primitive data type ____________.

Q. Which of the following data types comes under floating data types ?

Q. Which of the following values, cannot be stored using Character data type?

Q. Range of Byte Data Type is ____________.

Q. What is size of integer in Java Programming?

Q. Which of the following data type(s) can store 64 bit Value?

Q. Short data type has a minimum value of _____________.

Q. Default value of variable having boolean data type is ___________.

Q. Which of the following are legal lines of Java code?

1. int w = (int)888.8;
2. byte x = (byte)100L;
3. long y = (byte)100;
4. byte z = (byte)100L;

Q. Which of the following are legal lines of Java code?

1. int w = (int)888.8;
2. byte x = (byte)100L;
3. long y = (byte)100;
4. byte z = (byte)100L;

Q. Which of these coding types is used for data type characters in Java?

Q. Java array is a collection of ________.

Q. Array data access using _____.

Q. At time of array initialization which is necessary to specify?

Q. Java Array can allocate __________.

Q. Which of the following is an incorrect array declaration?

Q. Index in array start with ______.