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

Answer:

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

Yes.

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

Yes.

Practice

Perhaps you would like to practice? Assume that each row is independent of the others.

code sectionpointA == pointB pointA.equals( pointB )
Point pointA = new Point( 0, 0 );
Point pointB = new Point( 0, 0 );
Point pointA = new Point( 21, 17 );
Point pointB = pointA;
Point pointA = new Point( 21, 17 );
Point pointB = new Point( 7*3, 20-3 );
Point pointA = new Point( 21, 17 );
Point pointB = new Point( pointA );
Point pointA = new Point( 21, 17 );
Point pointB = new Point( 21, 17 );
pointA.move( 8, 12 );
Point pointA = new Point( 21, 17 );
Point pointB = pointA;
pointB.move( 8, 12 );

Notice that in the last question there is only one object, with two variables pointing to it. When the move() operation is performed, the data in that one object is changed. So it is still true that the data referred to by one reference variable is the same as that referred to by the the other. So equals() still reports true.

With aliases it is easy to get confused and think that there are two objects when in fact there is only one. Perhaps this is why bank robbers use aliases.


QUESTION 23:

Could an object have more than two aliases?


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