1  public class Point extends Object {
  2    
  3    // Instance variables:
  4    protected double x, y;
  5    
  6    // Constructors:
  7    public Point(double x, double y) {
  8      setX(x); setY(y);
  9    }
 10    public Point() { }  
 11    
 12    // Encapsulate the instance variables:
 13    public void setX(double x) {
 14      this.x = x;
 15    }
 16    public void setY(double y) {
 17      this.y = y;
 18    }
 19    public double getX() {
 20      return x;
 21    }
 22    public double getY() {
 23      return y;
 24    }
 25    
 26    // Instance methods:
 27    public String toString() {
 28      return super.toString();  // to be overridden
 29    }
 30    
 31  }