From 38961badd79ec4a5ce1a11ab6a4fd9b6ba278aa1 Mon Sep 17 00:00:00 2001 From: ivs Date: Wed, 23 Oct 2024 19:00:05 +0800 Subject: [PATCH] Improve comments --- T5Q2-C/src/Main.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/T5Q2-C/src/Main.java b/T5Q2-C/src/Main.java index a1ebe2d..45741c6 100644 --- a/T5Q2-C/src/Main.java +++ b/T5Q2-C/src/Main.java @@ -14,17 +14,15 @@ public class Main { // a.print(88); // Compilation error // IV - -// ClassA a = new ClassC(); // Ok -> Upcast A<-C -// ClassG g = (ClassG)a; // Compile Error on some JDKs -> Downcast G<-(A<-C) -// g.print("hello"); // RunTime error - // Upcast is prone to Compiler error and Runtime error - // Downcast is prone to Runtime error +// ClassA a = new ClassC(); // Ok +// ClassG g = (ClassG)a; // Runtime error +// g.print("hello"); // V - We lost track of the print(string, string) in C become it become a A first // ClassA a = new ClassC(); // ok -// ClassG g = (ClassG)a; // Compile Error on some JDKs -// g.print("hello", "there"); // Runtime error +// ClassG g = (ClassG)a; // Runtime error +// g.print("hello", "there"); // VI // ClassA a = new ClassF(); // OK