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

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

Moderator: admin

Post Reply
ETS User

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

Post by ETS User »

According to the question, I guess the classes should look like this:
MyClass
L--- OurClass
L---- YourClass

Since "OurClass contains a reference to YourClass" is correct according to the answer, why "MyClass contains a reference to OurClass" is wrong?

Guest

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

Post by Guest »

Edit:

MyClass
L--- OurClass
.......L---- YourClass

I thought that space will be displayed correctly. This is the updated one

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

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

Post by admin »

OurClass is a MyClass that means OurClass extends MyClass.
OurClass has a YourClass object means, there is a field of class YourClass in OurClass.

MyClass doesn't contain a field of class YourClass, OurClass does.
classdia.jpg
classdia.jpg (10.96 KiB) Viewed 6093 times

Sweetpin2
Posts: 27
Joined: Thu Feb 07, 2013 9:46 pm
Contact:

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

Post by Sweetpin2 »

admin wrote:OurClass is a MyClass that means OurClass extends MyClass.
OurClass has a YourClass object means, there is a field of class YourClass in OurClass.

MyClass doesn't contain a field of class YourClass, OurClass does.
classdia.jpg

Just a small correction to explanation

OurClass is a MyClass => OurClass extends  (or inherits from) MyClass. Thus, option 4(it should be option 5) is correct.

OurClass has a YourClass => OurClass refers to (or contains a reference to ) YourClass object. Thus, option 5(it should be option 4) is correct.

fabbbb
Posts: 3
Joined: Wed Aug 27, 2014 10:26 am
Contact:

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

Post by fabbbb »

OurClass contains a reference to MyClass
Isn't this correct in form of the super reference?

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

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

Post by admin »

No, super is not a reference to a separate object of the super class. It is just a way to refer the members of same object but inherited from the super class.

lagartija
Posts: 1
Joined: Wed Nov 29, 2017 1:53 pm
Contact:

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

Post by lagartija »

is this the correct code for it?

class MyClass {}

class OurClass extends MyClass {
YourClass yourclass= new YourClass();
}

class YourClass {}

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

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

Post by admin »

Yes, that is correct, lagartija.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], witek_m and 11 guests