Using inheritance (the "is a" relation). : Inheritance « Object Oriented « SCJP






class Rectangle {
  private int width = 0;

  private int height = 0;

  public void setSize(int w, int h) {
    this.width = w;
    this.height = h;
  }

}

class Window extends Rectangle {
  private String title;

  public void setTitle(String t) {
    this.title = t;
  }
}








6.3.Inheritance
6.3.1.Using inheritance (the "is a" relation).
6.3.2.Implementing Object-Oriented Relationships: A home is a house that has a family and a pet.