1. Subtyping in Java

Java provides built-in support for subtyping with its extends keyword, but it does not support multiple inheritance. Consider the following information design model:

First, we define the superclass Person. Then, we define the subclass Student and its subtype relationship to Person by means of the extends keyword:

public class Person {
  private String firstName;
  private String lastName;
public class Student extends Person {
  private int studentNo;

  public Student( String first, String last, int studNo) {
    super( firstName, lastName);
    this.setStudNo( studNo);

Notice that in the Student class, we define a constructor with all the parameters required to create an instance of Student. In this subclass constructor we use super to invoke the constructor of the superclass Person.