I understand the explanation. I just disagree with the assumption made in it. Why would we assume to be in the com.enthu package? If we do the comparison outside the package then we clearly use the "usual" equals method using Object as a parameter. The answer is still the same so its an academic point.admin wrote:Explanation is talking about equals(Resource ) because that is how the method is coded in the given code. This method is causing the problem discussed in the explanation and above.
I am still not sure what you mean by "should be used". Do you mean the JVM should automatically figure out which method should be used or do you mean the developer should code only equals(Object ) method and should not code equals(Resource )?
Anyway, the fact is that the given code contains equals(Resource ) method and the question expects you to determine what will happen. The explanation explains exactly what happens. Please go through it.
-Paul.
"if two distinct Resource objects are considered equal, it means that the comparison has been done from a class that belongs to com.enthu package"