About Question enthuware.ocajp.i.v7.2.1160 :
Moderator: admin
About Question enthuware.ocajp.i.v7.2.1160 :
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?
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?
Re: About Question enthuware.ocajp.i.v7.2.1160 :
Edit:
MyClass
L--- OurClass
.......L---- YourClass
I thought that space will be displayed correctly. This is the updated one
MyClass
L--- OurClass
.......L---- YourClass
I thought that space will be displayed correctly. This is the updated one
-
- Site Admin
- Posts: 10046
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1160 :
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.
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.
If you like our products and services, please help us by posting your review here.
-
- Posts: 27
- Joined: Thu Feb 07, 2013 9:46 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1160 :
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.
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.
-
- Posts: 3
- Joined: Wed Aug 27, 2014 10:26 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1160 :
Isn't this correct in form of the super reference?OurClass contains a reference to MyClass
-
- Site Admin
- Posts: 10046
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1160 :
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.
If you like our products and services, please help us by posting your review here.
-
- Posts: 1
- Joined: Wed Nov 29, 2017 1:53 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1160 :
is this the correct code for it?
class MyClass {}
class OurClass extends MyClass {
YourClass yourclass= new YourClass();
}
class YourClass {}
class MyClass {}
class OurClass extends MyClass {
YourClass yourclass= new YourClass();
}
class YourClass {}
-
- Site Admin
- Posts: 10046
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1160 :
Yes, that is correct, lagartija.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: Baidu [Spider] and 66 guests