Question: Having some problems with some computer science homework. I bolded two of the answers that I'm stuck between. Please help, thank you!! Questions 18 -
Having some problems with some computer science homework.
I bolded two of the answers that I'm stuck between. Please help, thank you!!
Questions 18 - 19 pertain to the following class, Point:
public class Point {
private double x;
private double y;
public Point() {
this (0, 0);
}
public Point(double a, double b) {
/* missing code */
}
// ... other methods not shown
}
Which of the following correctly implements the equals method?
public boolean equals(Point p) {
return (x == Point.x && y == Point.y);
}
public void equals(Point p) {
System.out.println(x == p.x && y == p.y);
}
public boolean equals(Point p) {
System.out.println(x == p.x && y == p.y);
}
public boolean equals(Point p) {
return (x == p.x && y == p.y );
}
public void equals(Point p) {
return (x == p.x && y == p.y );
}
The default constructor sets x and y to (0, 0) by calling the second constructor. What could be used to replace /* missing code */ so that this works as intended?
a = 0;
b = 0;
this(0, 0);
this (x, y);
a = x;
b = y;
x = a;
y = b;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
