About Question enthuware.ocajp.i.v7.2.1328 :

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

Moderator: admin

Dreamweaver
Posts: 32
Joined: Mon Dec 29, 2014 4:14 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1328 :

Post by Dreamweaver »

I dissected the situation a bit to better understand and I came to the next summary:

interface I { }
class A implements I { }
class B extends A { }
class C extends B { }

public class CastTwice {
public static void main(String[] args) {
A a = new A();
B b = new B();

//a = (B)(I)b; is the same with:

I x = (I) b; // x is type I and is pointing to a B object //Possible because B is-a I
a = (B) x; // x is-a B and so, x is-a a //Possible because B is-a A


casting3.jpg
casting3.jpg (9.2 KiB) Viewed 1963 times
Is that correct?

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

Re: About Question enthuware.ocajp.i.v7.2.1328 :

Post by admin »

At the end of the statement, a should be pointing to the B object.
If you like our products and services, please help us by posting your review here.

Dreamweaver
Posts: 32
Joined: Mon Dec 29, 2014 4:14 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1328 :

Post by Dreamweaver »

Thank you very much, I updated the image:
casting6.jpg
casting6.jpg (10.27 KiB) Viewed 1960 times

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

Re: About Question enthuware.ocajp.i.v7.2.1328 :

Post by admin »

Looks good now :)
If you like our products and services, please help us by posting your review here.

jpena112
Posts: 1
Joined: Wed Oct 06, 2021 1:32 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1328 :

Post by jpena112 »

Can you explain more towards this answer

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

Re: About Question enthuware.ocajp.i.v7.2.1328 :

Post by admin »

Can you please tell us which part do you have a difficulty understanding so that we can explain that?

You may also go through the responses posted above.
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 30 guests