go to previous page   go to home page   go to next page hear noise

If the == operator returns a true will the equals() method return a true, always?

Answer:

Yes.


Summary

The following table is a summary. There are four rows, one for each choice of true and false. The last row shows a choice that is not possible. If == is true, there is only one object, which must be equals to itself.

code sectionpointA == pointB pointA.equals( pointB )
Point pointA = new Point( 21, 17 );
Point pointB = pointA;
truetrue
Point pointA = new Point( 21, 17 );
Point pointB = new Point( -99, 86 );
falsefalse
Point pointA = new Point( 21, 17 );
Point pointB = new Point( 21, 17 );
falsetrue
Not Possible
truefalse

QUESTION 22:

Does pointA.equals(pointB) return the same true/false value as pointB.equals(pointA) ?

Does pointA == pointB return the same true/false value as pointB == pointA ?


go to previous page   go to home page   go to next page