[HD Pg 0, Sec. 11.3.1 - bridging-the-gap-between-compile-time-and-run-time]

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
natasci
Posts: 6
Joined: Fri Mar 15, 2019 4:40 am
Contact:

[HD Pg 0, Sec. 11.3.1 - bridging-the-gap-between-compile-time-and-run-time]

Post by natasci »

Hi, at the page 308 given the code snippet:

Code: Select all

Mango m = new Mango();
Apple a = (Mango) m;
And then the explanation:
The compiler rejects the above code in spite of you guaranteeing that m will point to an Apple
at run time.
According to the explanation above shouldn't the code be:

Code: Select all

Mango m = new Mango();
Apple a = (Apple) m;

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: [HD Pg 0, Sec. 11.3.1 - bridging-the-gap-between-compile-time-and-run-time]

Post by admin »

You are right. It should be:
Mango m = new Mango();
Apple a = (Apple) m;

Added to errata. thank you for your feedback!
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 33 guests