package Klausur.mensch;

public class Mensch {
    int alter;

    public Mensch(int alter) {
        this.alter = alter;
    }

    @Override
    public String toString() {
        return "Mensch(" + alter + ")";
    }
    
    public static void main(String[] args) {
        Student s = new Student(20, 12345);
        Object o =  s;
        Mensch m = s;

        System.out.println(o.toString()); // 1) Ausgabe: Student(12345)
        System.out.println(m.toString()); // 2) Ausgabe: Student(12345)
        System.out.println(s.toString()); // 3) Ausgabe: Student(12345)
    }
}

class Student extends Mensch {
    int matrnr;

    public Student(int alter, int matrikelnummer) {
        super(alter);
        this.matrnr = matrikelnummer;
    }

    @Override
    public String toString() {
        return "Student(" + matrnr + ")";
    }
}

