About Question enthuware.ocajp.i.v8.2.2014 :

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

Moderator: admin

actuaris
Posts: 3
Joined: Mon Feb 27, 2017 4:52 am
Contact:

About Question enthuware.ocajp.i.v8.2.2014 :

Post by actuaris »

I thought that if you have:

class A (int a = 5;}
class B extends A {int b = 10;}
class C extends B {int c = 2;}

would count as inheriting mutiple states for any instance of class C (it inherits both A's and B's state). Can you explain why this reasoning is false?

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

Re: About Question enthuware.ocajp.i.v8.2.2014 :

Post by admin »

From OOP perspective, C inherits only the state of B.
class B includes the state of A. C doesn't directly inherit the state of A.
This is the view adopted by the official Java tutorial as well - https://docs.oracle.com/javase/tutorial ... tance.html

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

actuaris
Posts: 3
Joined: Mon Feb 27, 2017 4:52 am
Contact:

Re: About Question enthuware.ocajp.i.v8.2.2014 :

Post by actuaris »

Thanks, I'll remember it for the exam.

lenalena
Posts: 56
Joined: Tue Feb 21, 2017 4:24 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.2014 :

Post by lenalena »

This question threw me off because the last option states:

"Multiple inheritance of type includes the ability to implement multiple interfaces and/or ability to extend from multiple classes"

I am not sure about "ability to extend from multiple classes" part of the answer choice... Wouldn't that apply to multiple inheritance of state, not type? Also, from the explanation, it says that a "class can extend only from one class at most". So even IF the above definition of multiple inheritance of type was correct (and I'm not sure why it is, but since it's marked as a correct answer, it must be) it would still be a wrong option, because Java doesn't allow an "ability to extend from multiple classes".

I am very confused (by a topic I thought I understood up to this question).

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

Re: About Question enthuware.ocajp.i.v8.2.2014 :

Post by admin »

The statement is talking about multiple inheritance of type. Classes and interfaces are both types.

Java allows multiple inheritance of only interfaces. So in that sense Java does allow multiple inheritance of types.
A Class has a state as well. Java does not allow inheriting from multiple classes. That means Java does not allow multiple inheritance of state.

You should go through the link posted above for more detailed explanation.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

lenalena
Posts: 56
Joined: Tue Feb 21, 2017 4:24 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.2014 :

Post by lenalena »

admin wrote:The statement is talking about multiple inheritance of type. Classes and interfaces are both types.

Java allows multiple inheritance of only interfaces. So in that sense Java does allow multiple inheritance of types.
A Class has a state as well. Java does not allow inheriting from multiple classes. That means Java does not allow multiple inheritance of state.

You should go through the link posted above for more detailed explanation.

HTH,
Paul.
So you're saying that this particular option is talking about a theoretical (not specific to Java) "inheritance of type" which can include inheritance of multiple classes. Because if you're applying the concept of "inheritance of type" specifically to Java, then "in that sense" the option is not correct because it's talking about extending multiple classes.

I understand the theory behind multiple inheritance of type as it applies to Java, I read the link, and it's all clear. I just don't understand (still, even after your explanation) why the above option is correct. Don't the questions in the exam relate to the Java language specifically?

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

Re: About Question enthuware.ocajp.i.v8.2.2014 :

Post by admin »

That is correct. There is no reference to Java in that statement. It is a statement just about multiple inheritance of type. The statement has "and/or". Not just "and". So even for Java, the statement is correct because of the "or" part.
If you like our products and services, please help us by posting your review here.

lenalena
Posts: 56
Joined: Tue Feb 21, 2017 4:24 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.2014 :

Post by lenalena »

admin wrote:That is correct. There is no reference to Java in that statement. It is a statement just about multiple inheritance of type. The statement has "and/or". Not just "and". So even for Java, the statement is correct because of the "or" part.
Thanks, the answer option is clear now.

zserrbo
Posts: 2
Joined: Tue Feb 28, 2017 2:33 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.2014 :

Post by zserrbo »

The question has also other two answer:
Multiple inheritance of state includes ability to inherit instance methods from multiple classes.
Multiple inheritance of state includes ability to inherit instance fields from multiple classes.

I don't understand. Why are they good answers?

From the explanation:
""State", on the other hand, is represented by instance fields and instance methods. "
"Thus, Java does not support multiple inheritance of state."

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

Re: About Question enthuware.ocajp.i.v8.2.2014 :

Post by admin »

These options are correct because they are factually correct about the meaning of the term "Multiple inheritance of state".
It is true that Java does not support multiple inheritance of state but options don't claim so either. So there is nothing wrong with the options.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

crazymind
Posts: 85
Joined: Mon Dec 24, 2018 6:24 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.2014 :

Post by crazymind »

Hi, I wonder if the real test could contain any questions regarding the multiple inheritance?

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

Re: About Question enthuware.ocajp.i.v8.2.2014 :

Post by admin »

Yes, questions on this concept are asked in the real exam.
If you like our products and services, please help us by posting your review here.

crazymind
Posts: 85
Joined: Mon Dec 24, 2018 6:24 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.2014 :

Post by crazymind »

Thanks.
Multiple inheritance of state includes ability to inherit instance fields from multiple classes.

I don't quite understand why is this one correct answers ? Isn't multiple inheritance including inherit instance fields and instance methods from multiple classes?

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

Re: About Question enthuware.ocajp.i.v8.2.2014 :

Post by admin »

No, state means fields. Not methods. Please go through the discussion above.
If you like our products and services, please help us by posting your review here.

Chris1
Posts: 1
Joined: Sun Aug 16, 2020 1:34 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.2014 :

Post by Chris1 »

maybe I was a bit quick here but I ruled out the correct answer
Multiple inheritance of type includes ability to implement multiple interfaces and/or ability to extend from multiple clases.
because there are no "clases" in java, only "classes" (as stated in the other answers). Good to know the exam does not ask questions on that ;)

baichen7788
Posts: 23
Joined: Fri Mar 26, 2021 7:25 am
Contact:

Re: About Question enthuware.ocajp.i.v8.2.2014 :

Post by baichen7788 »

why is last option correct?
java only allows to extend from one class.
can you give an example on how java extends from multiple classes?

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

Re: About Question enthuware.ocajp.i.v8.2.2014 :

Post by admin »

Please read the responses given above. Already answered exactly the same query above.
If you like our products and services, please help us by posting your review here.

baichen7788
Posts: 23
Joined: Fri Mar 26, 2021 7:25 am
Contact:

Re: About Question enthuware.ocajp.i.v8.2.2014 :

Post by baichen7788 »

I don't know which response above answered my question.

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

Re: About Question enthuware.ocajp.i.v8.2.2014 :

Post by admin »

There is no reference to Java in the last option. It is just a statement about multiple inheritance of type, which includes extending from multiple interefaces (Java allows that) and / or multiple classes (Java doesn't allow that).

The statement has "and/or". Not just "and". So, even for Java, the statement is correct because of the "or" part.
If you like our products and services, please help us by posting your review here.

enthunoob
Posts: 60
Joined: Thu Apr 15, 2021 12:21 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.2014 :

Post by enthunoob »

The last option is marked as correct but that's impossible as clases don't exist in OOP. Classes do though. :mrgreen:
Multiple inheritance of type includes ability to implement multiple interfaces and/or ability to extend from multiple clases.

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

Re: About Question enthuware.ocajp.i.v8.2.2014 :

Post by admin »

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

Badem48
Posts: 26
Joined: Thu Aug 24, 2023 4:33 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.2014 :

Post by Badem48 »

Hi,

I am confused about one subject of this option "Multiple inheritance of type includes ability to implement multiple interfaces and/or ability to extend from multiple classes."

At https://docs.oracle.com/javase/tutorial ... tance.html it says "The Java programming language supports multiple inheritance of type, which is the ability of a class to implement more than one interface. An object can have multiple types: the type of its own class and the types of all the interfaces that the class implements. This means that if a variable is declared to be the type of an interface, then its value can reference any object that is instantiated from any class that implements the interface."

However, this option also add "... and/or ability to extend from multiple classes." Is this right?

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

Re: About Question enthuware.ocajp.i.v8.2.2014 :

Post by admin »

The statement, ""Multiple inheritance of type includes ability to implement multiple interfaces and/or ability to extend from multiple classes." is correct because it means Multiple inheritance of type can be achieved either by implementing multiple interface or by extending from multiple classes or both.

Java doesn't support the ability to extend from multiple classes but that is not what the above statement claims.

Please go through the responses above.
If you like our products and services, please help us by posting your review here.

Badem48
Posts: 26
Joined: Thu Aug 24, 2023 4:33 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.2014 :

Post by Badem48 »

I am sorry maybe I am missing something here but on the Oracle documentation it does not mentioned anything about "inheritance of type ... ability to extend from multiple classes" . It is state the fact Java supports multiple inheritance of type by implementing more than one interface.

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

Re: About Question enthuware.ocajp.i.v8.2.2014 :

Post by admin »

That is because the Oracle page is talking about Java. The statement in the question is talking about multiple inheritance of type in general.
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 41 guests