For the same class what would a getter for the instance vari

For the same class

what would a getter for the instance variable x look like?

public double getX() {
return p1.x;
}

public double getX() {
return x;
}

public double getX(double newX) {
x = newX;
}

public double getX() {
return p1.x;
}

Solution

Answer:

public double getX() {
return x;
}

For this class, getter method looks lke above.

For the same class what would a getter for the instance variable x look like? public double getX() { return p1.x; } public double getX() { return x; } public do

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site