From 9240342b366db9999f11659a1f1c396ba418ad78 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Sat, 7 Jan 2023 18:51:03 +0100 Subject: Adds --- Year_2/SE/error_inheritance/Main.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Year_2/SE/error_inheritance/Main.java (limited to 'Year_2/SE/error_inheritance/Main.java') diff --git a/Year_2/SE/error_inheritance/Main.java b/Year_2/SE/error_inheritance/Main.java new file mode 100644 index 0000000..206a513 --- /dev/null +++ b/Year_2/SE/error_inheritance/Main.java @@ -0,0 +1,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(); + } +} -- cgit v1.2.3-18-g5258