Outline



Abstract Data Types



Java Interfaces



Java Interfaces



ADT design



Java classes and objects



Special methods



Inheritance



Special class variables: this and super

  • the predefined field this in the code of any class refers to the object of this class
  • the predefined field super in the code of a subclass refers to the object of the superclass:
    public class Child extends Parent {
      private String myName;
      public Child (String name)
      {
        super ();      /* call no-argument constructor for parent */
        this.myName = name; /* initialize local data */
      }
      /* omitting the hasFeature method would give the same result */
      public boolean hasFeature(String feature)
      {
        return super.hasFeature(feature);
      }
      public String name()
      {
        return myName;
      }
    }