Discussion :: Objects and Collections - Pointing out the correct statements (Q.No.4)
Arush said: (Dec 22, 2014) | |
Can anybody explain 4th one? |
Arush said: (Dec 22, 2014) | |
Can anybody explain 4th one? |
Charu said: (Aug 23, 2015) | |
4) equals() can be true even if it's comparing different objects. Basically equals() method is use to compare two different object. And return true/false. But if we are talking about hashcode() it returns "true" when object is same type. Against this statement equals() method can be "true" if we are comparing two different object but having same contains. |
Przemulala said: (May 16, 2016) | |
I've overridden only equals() and the code compiles and executes. Seems there's an error in the answers. OFC you should override both of them, but technically, it seems you don't have to do it mandatory. |
Bix said: (Dec 24, 2016) | |
So is this true? > Object().equals(new Object());. If someone agrees on this statement then question must have been formulated differently. In contrary the question as it is inadequate. |
Pratik said: (May 3, 2019) | |
Option C is incorrect. Hashcode method returns same value only if it called by same object. |
Post your comments here:
Name *:
Email : (optional)
» Your comments will be displayed only after manual approval.