public class Point { private int x; private int y; public void setx(int x) this.x = x; public void setY(int y) this.y=y; public void setXY(int x, int y) X=y; ysy; public boolean IsEqual(Point p) return ((p.x == x) && (p.y == y)); public void DisplayPoint() System.out.println("(" + x + " +X+ + y + ")"); public void movePoint(int deltax, int deltay) {!! 'x' is increased by deltax and y is increased by deltay public void SetLocation(Point P) {//make point to have the specified location P. public static void main(String[] args) { // TODO Auto-generated method stub Point P1 = new Point(); Point P2 = new Point(); P1.setx(5); P1.setY(6); P2.setx(5); P2.setY(6); System.out.println(P1.IsEqual(P2)); P2.setXY(3,4); System.out.println(P1.IsEqual(P2)); Given the class 'Point' which has two member variables x, and y. What are x and y for Point object P1 after the end of the main method ? (Pay close attention to the setXY method) x=6, y=5 Ox=6, y= 6 x=5, y= 6 x=5, y= 5

Respuesta :

Answer:

x =5

y =6

Explanation:

The reason behind that is that while using the reference P2 we have setted the values of X and Y both as 5 and 6 respectively in the main function.

After setting we are calling the setXY function which sets the value to 3 and 4 for X and Y respectively but does not implement in the value to the instance.

Apart from which setX and setY function are setting the values with respect to the instance variable using "this" keyword.

Hence, the values 5 and 6 are been displayed at the end of the main method.