Page 1 of 1
About Question enthuware.ocpjp.v8.2.1088 :
Posted: Wed Mar 09, 2016 5:41 pm
by digitalillusion
Hello,
I interpreted the question this way. It says: "aggregate features from multiple classes" so I immediately excluded inheritance, which is from a single class. While interface implementation, due to default and static method, is indeed aggregating features.
How would you argument the wrongness of my assumptions? Thank you.
Re: About Question enthuware.ocpjp.v8.2.1088 :
Posted: Wed Mar 09, 2016 11:27 pm
by admin
Your argument is valid but the question says from a "strictly OO perspective". In a strict OO sense, interfaces are not supposed to contain any implementation.
In the real exam, you should observe the wording of the question and decide whether it is asking about strict OO perspective or pure Java perspective.
HTH,
Paul.
Re: About Question enthuware.ocpjp.v8.2.1088 :
Posted: Fri Aug 05, 2016 6:47 am
by zhy2002
But you cannot inherit from multiple classes?
Re: About Question enthuware.ocpjp.v8.2.1088 :
Posted: Fri Aug 05, 2016 12:21 pm
by admin
That is correct. Java doesn't allow a class to extend from multiple classes. But this question is purely from an OO perspective.
Re: About Question enthuware.ocpjp.v8.2.1088 :
Posted: Sat Jun 24, 2017 11:38 am
by UncleF
So if the same question will be asked from Java perspective then
- Composition
and
- Interface implementation
will be correct answers?
Because I remember a similar question from OCA exam and there was citation from official Java documents about interfaces being the Java way of multiple inheritance.
Re: About Question enthuware.ocpjp.v8.2.1088 :
Posted: Sat Jun 24, 2017 8:52 pm
by admin
Yes, that is correct.
Re: About Question enthuware.ocpjp.v8.2.1088 :
Posted: Tue Apr 24, 2018 6:02 pm
by thodoris.bais
admin wrote:Your argument is valid but the question says from a "strictly OO perspective". In a strict OO sense, interfaces are not supposed to contain any implementation.
In the real exam, you should observe the wording of the question and decide whether it is asking about strict OO perspective or pure Java perspective.
HTH,
Paul.
Still this does not say anything to me about how the aggregation of features from multiple classes is related to the inheritance concept
Re: About Question enthuware.ocpjp.v8.2.1088 :
Posted: Tue Apr 24, 2018 8:51 pm
by admin
When you extend a class, you do get features from that class, right? If you inherit from multiple classes (not possible in Java but possible in C++), you will get features from multiple classes in your class.
As mentioned in the text that you've quoted, "In a strict OO sense, interfaces are not supposed to contain any implementation." If there is no implementation then how will you aggregate features by implementing interfaces?
Static methods have nothing to do with OOP.
Re: About Question enthuware.ocpjp.v8.2.1088 :
Posted: Fri Apr 27, 2018 5:00 am
by thodoris.bais
I think I get it now, the question probably implies "when used together" in the section about the code reuse techniques. So, the meaning is that composition together with inheritance can be used to aggregate features from multiple classes.
I thought the question meant "when used individually"
Re: About Question enthuware.ocpjp.v8.2.1088 :
Posted: Fri Apr 27, 2018 5:08 am
by admin
No, not together with composition. Composition and inheritance are two different techniques and both, individually, do reuse code and aggregate features from multiple classes.