next up previous
Next: Fundamental features of derived Up: Unit 03 Previous: Inheritance

Inheritance: example

We derive the subclass Student from the class Person as follows:

public class Student extends Person {
  private String faculty;

  public Student(...) {   // constructor
    ...
  }

  public String getFaculty() {
    return faculty;
  }
}

The objects of the class Student are characterized by the properties inherited from the class Person and additionally by the faculty at which the student is registered.


next up previous
Next: Fundamental features of derived Up: Unit 03 Previous: Inheritance