Which changes stay hidden from clients

Dozens of other classes use the Java class below, and every one of them uses it only through its public methods.


Java
public class Rectangle {
    private double width;   // metres
    private double height;  // metres

    public double getWidth() { return width; }
    public void setWidth(double w) { if (w > 0) width = w; }
    public double getHeight() { return height; }
    public void setHeight(double h) { if (h > 0) height = h; }
    public double getArea() { return width * height; }
}


Which of the following changes can the author make without editing any line of client code and without changing the values clients receive? Select all that apply.

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Encapsulation and Information Hiding Questions: