Play audio slide show -- Keyboard shortcut: 'x'  Lecture overview -- Keyboard shortcut: 'u'  Previous page: Checkkonto er både en udvidelse og en specialisering af Konto -- Keyboard shortcut: 'p'  Next page: Eksempel på nedarvning: DoubleLinkable -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  Annotated slide -- Keyboard shortcut: 't'  Alphabetic index  Help page about these notes  Course home  Play sound for this slide -- Keyboard shortcut: 'y'    Nedarvning - slide 16 : 41

Eksempel på nedarvning: Triple 

Pair.javaJava klassen Pair.
 

class Triple extends Pair {

  protected Object part3;

  public Triple(Object part1, Object part2, Object part3){
    super(part1,part2);
    this.part3 = part3;
  }

  public Object part3(){
    return(part3);
  }

  public void setPart3(Object newPart){
   part3 = newPart;
  }

  public String toString(){
    return("Triple: " + part1.toString() + 
           ", " + part2.toString() +
           ", " + part3.toString());
  }

}