[HD Pg 0, Sec. 11.3.1 - bridging-the-gap-between-compile-time-and-run-time]
Posted: Wed May 15, 2019 11:10 am
Hi, at the page 308 given the code snippet:
And then the explanation:
Code: Select all
Mango m = new Mango();
Apple a = (Mango) m;
According to the explanation above shouldn't the code be:The compiler rejects the above code in spite of you guaranteeing that m will point to an Apple
at run time.
Code: Select all
Mango m = new Mango();
Apple a = (Apple) m;