summaryrefslogtreecommitdiff
path: root/Year_2/SE/error_inheritance/Main.java
blob: 206a513eeecd0fff02d04d85706d95b5333c46d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
public class Main {
    public static void main(String[] args) {
        Student s = new Student();
        s.setName("Santo");
        s.setMatr("1948");

        s.print();

        Person p = s;
        // That's not compile
        // p.setMatr("1949");
        p.setName("John");
        p.print();

        // s.name is equals to p.name, so the code below print
        // Hello, John[...]
        s.print();
    }
}