What’s the Output?
a. Determine the output of the following code:
public class Point { int x, y; public Point () { x = y = 0; } public Point(int a, int b) { x = a; y = b; } public boolean equals(Point p) // tests whether or not two Points are equal { return ( p.x == x && p.y == y); } } public class Example { public static void main(String[] args) { Object a; Object b; a = new Point(3, 4); b = new Point (3, 4); System.out.println(a.equals(b)); } }b. Determine the output of the following code:
public class Point { int x, y; public Point () { x = y = 0; } public Point(int a, int b) { x = a; y = b; } public boolean equals(Point p) // tests whether or not two Points are equal { return ( p.x = = x && p.y = = y); } } public class Example { public static void main(String[] args) { Object a; Object b; a = new Point(3, 4); b = a; System.out.println(a.equals(b)); } }
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.