About Question enthuware.ocajp.i.v8.2.2014 :
Moderator: admin
-
- Posts: 3
- Joined: Mon Feb 27, 2017 4:52 am
- Contact:
About Question enthuware.ocajp.i.v8.2.2014 :
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?
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?
Online
-
- Site Admin
- Posts: 10103
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.2014 :
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.
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.
-
- Posts: 3
- Joined: Mon Feb 27, 2017 4:52 am
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.2014 :
Thanks, I'll remember it for the exam.
-
- Posts: 56
- Joined: Tue Feb 21, 2017 4:24 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.2014 :
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).
"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).
Online
-
- Site Admin
- Posts: 10103
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.2014 :
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.
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.
-
- Posts: 56
- Joined: Tue Feb 21, 2017 4:24 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.2014 :
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.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.
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?
Online
-
- Site Admin
- Posts: 10103
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.2014 :
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.
-
- Posts: 56
- Joined: Tue Feb 21, 2017 4:24 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.2014 :
Thanks, the answer option is clear now.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.
-
- Posts: 2
- Joined: Tue Feb 28, 2017 2:33 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.2014 :
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."
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."
Online
-
- Site Admin
- Posts: 10103
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.2014 :
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.
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.
-
- Posts: 85
- Joined: Mon Dec 24, 2018 6:24 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.2014 :
Hi, I wonder if the real test could contain any questions regarding the multiple inheritance?
Online
-
- Site Admin
- Posts: 10103
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.2014 :
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.
-
- Posts: 85
- Joined: Mon Dec 24, 2018 6:24 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.2014 :
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?
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?
Online
-
- Site Admin
- Posts: 10103
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.2014 :
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.
-
- Posts: 1
- Joined: Sun Aug 16, 2020 1:34 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.2014 :
maybe I was a bit quick here but I ruled out the correct answer
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 thatMultiple inheritance of type includes ability to implement multiple interfaces and/or ability to extend from multiple clases.
-
- Posts: 23
- Joined: Fri Mar 26, 2021 7:25 am
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.2014 :
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?
java only allows to extend from one class.
can you give an example on how java extends from multiple classes?
Online
-
- Site Admin
- Posts: 10103
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.2014 :
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.
-
- Posts: 23
- Joined: Fri Mar 26, 2021 7:25 am
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.2014 :
I don't know which response above answered my question.
Online
-
- Site Admin
- Posts: 10103
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.2014 :
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.
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.
-
- Posts: 60
- Joined: Thu Apr 15, 2021 12:21 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.2014 :
The last option is marked as correct but that's impossible as clases don't exist in OOP. Classes do though.
Multiple inheritance of type includes ability to implement multiple interfaces and/or ability to extend from multiple clases.
Online
-
- Site Admin
- Posts: 10103
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.2014 :
Fixed.
thank you for your feedback!
thank you for your feedback!
If you like our products and services, please help us by posting your review here.
-
- Posts: 28
- Joined: Thu Aug 24, 2023 4:33 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.2014 :
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?
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?
Online
-
- Site Admin
- Posts: 10103
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.2014 :
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.
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.
-
- Posts: 28
- Joined: Thu Aug 24, 2023 4:33 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.2014 :
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.
Online
-
- Site Admin
- Posts: 10103
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.2014 :
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.
Who is online
Users browsing this forum: No registered users and 16 guests