About Question enthuware.ocpjp.v11.2.3382 :
Moderator: admin
-
- Posts: 6
- Joined: Tue Jan 26, 2021 9:24 am
- Contact:
About Question enthuware.ocpjp.v11.2.3382 :
Why is it required to add @Override here?
I think option 3 should be correct here. Or is this a question about good practice instead of compiler rules?
I think option 3 should be correct here. Or is this a question about good practice instead of compiler rules?
-
- Site Admin
- Posts: 10152
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3382 :
It is not required. That is why option 1 says "should" not "must". The comment inside the code in the problem statement says that the equals method intends to override the superclass's equals. So, @Override annotation should be applied.
If you like our products and services, please help us by posting your review here.
-
- Posts: 9
- Joined: Mon Dec 14, 2020 8:53 am
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3382 :
If this is the kind of trick questions that i will get in the exam, i rather give up
No way there is no ambiguity here. I would never consider the should word to be a hint in this case.
That explanation would be more acceptable if the class A was extending another class that we wouldn't know nothing about. But in this case implicitly extends Object. Sorry but no way the @Override must or should be applied!
I mean, are we testing our Java knowledge or our ability to be clever?
![Neutral :|](./images/smilies/icon_neutral.gif)
No way there is no ambiguity here. I would never consider the should word to be a hint in this case.
That explanation would be more acceptable if the class A was extending another class that we wouldn't know nothing about. But in this case implicitly extends Object. Sorry but no way the @Override must or should be applied!
I mean, are we testing our Java knowledge or our ability to be clever?
-
- Site Admin
- Posts: 10152
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3382 :
While you may get trick questions in the exam but I am sorry, but I do not find this question tricky. Annotations, including the @Overide are on the exam and this question tests you precisely on whether you know how and where it "should" be used.
Also, the exam does expect you to make the distinction between the words must/may/can/cannot and should. "must" implies a firm requirement while may implies that it is not required but is not an error to do so. Should implies that it is not a compilation error or anything but is a good or recommended practice. Just make a mental note of them and you should be ok.
HTH,
Paul.
Also, the exam does expect you to make the distinction between the words must/may/can/cannot and should. "must" implies a firm requirement while may implies that it is not required but is not an error to do so. Should implies that it is not a compilation error or anything but is a good or recommended practice. Just make a mental note of them and you should be ok.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 9
- Joined: Mon Dec 14, 2020 8:53 am
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3382 :
Thank you for your reply.
Sorry, but I am still not able to agree with your point of view and the structure of this question.
Yes, i know that annotations are part of the exam... In this case we have a method that does not override any other method, a sneaky comment that says "//override the equals methods" and a choice of answers like "@Override should be applied at //1" and "There is no need to apply @Override at //1". All this and knowing that one of the correct answers is that @Override should be applied, makes this question to me tricky.
I think there is a conflict here between intent and logic.
By intent I agree that @Override should be applied. But we have another answer stating "Applying @Override.. cause compilation failure.". So to me it confuses people between facing with logic and intent. The logic here is, the method absolutely does not override equals hence @Override should not be applied. "There is no need to apply.." not the most adequate statement but still better than saying that it should be applied in this case.
Well, just my opinion.
Cheers.
Sorry, but I am still not able to agree with your point of view and the structure of this question.
Yes, i know that annotations are part of the exam... In this case we have a method that does not override any other method, a sneaky comment that says "//override the equals methods" and a choice of answers like "@Override should be applied at //1" and "There is no need to apply @Override at //1". All this and knowing that one of the correct answers is that @Override should be applied, makes this question to me tricky.
I think there is a conflict here between intent and logic.
By intent I agree that @Override should be applied. But we have another answer stating "Applying @Override.. cause compilation failure.". So to me it confuses people between facing with logic and intent. The logic here is, the method absolutely does not override equals hence @Override should not be applied. "There is no need to apply.." not the most adequate statement but still better than saying that it should be applied in this case.
Well, just my opinion.
Cheers.
-
- Site Admin
- Posts: 10152
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3382 :
I see your point. Will update the problem statement to make the intention of the code clear.
The main benefit of @Override is to ensure that the intention is captured correctly by the method. So, if you put the @Override annotation but the method does not actually override any method, then the compiler will flag an error. This is what this question is trying to get at.
thank you for your feedback!
The main benefit of @Override is to ensure that the intention is captured correctly by the method. So, if you put the @Override annotation but the method does not actually override any method, then the compiler will flag an error. This is what this question is trying to get at.
thank you for your feedback!
If you like our products and services, please help us by posting your review here.
-
- Posts: 2
- Joined: Thu Apr 29, 2021 10:17 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3382 :
The question says the correct options are :
@Override should be applied at //1.
Applying @Override at //1 will cause compilation failure.
This both statements are contradicting for the answers. I won't say this is a tricky question, instead it is wrong. This option (@Override should be applied at //1.) must be removed from the options list. Or change this to '@Override should not be applied at //1.' In this case the correct options list will be 3 not 2.
The another option 'There is no need to apply @Override at //1.' is suitable in this case.
@Override should be applied at //1.
Applying @Override at //1 will cause compilation failure.
This both statements are contradicting for the answers. I won't say this is a tricky question, instead it is wrong. This option (@Override should be applied at //1.) must be removed from the options list. Or change this to '@Override should not be applied at //1.' In this case the correct options list will be 3 not 2.
The another option 'There is no need to apply @Override at //1.' is suitable in this case.
-
- Site Admin
- Posts: 10152
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3382 :
Thank you for your feedback but in our view the question is fine. Please go through the discussion above.
If you like our products and services, please help us by posting your review here.
-
- Posts: 2
- Joined: Fri Aug 06, 2021 7:46 am
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3382 :
Yeah.. It's super tricky.. 3 is way better than 1.
-
- Posts: 1
- Joined: Mon Oct 04, 2021 10:56 am
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3382 :
Please change it from 1 to 3.
Low quality question.
Low quality question.
-
- Posts: 14
- Joined: Fri Apr 12, 2024 11:09 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3382 :
I read the discussion, and it only proves that option 3 should be the right one. As admin have said above:
"Also, the exam does expect you to make the distinction between the words must/may/can/cannot and should."
If we're going to take this serious, than option 3 statement "There is no need to apply @Override at //1." is correct. Because yeah, there's no NEED to apply. You can not apply it.
And as others have said, Option 1 "@Override should be applied at //1" is not correct, because if I know that this will cause compilation error (option 2), than why should I do it? I literally saw that the contract for equals method was wrong, and I know the code will not compile with @Override, so why should I do it? When there's a option that clearly says "there is no need to apply"?
If this question had only 1 right option to select, it would be okay, because Option 2 is the only the really makes sense.
"Also, the exam does expect you to make the distinction between the words must/may/can/cannot and should."
If we're going to take this serious, than option 3 statement "There is no need to apply @Override at //1." is correct. Because yeah, there's no NEED to apply. You can not apply it.
And as others have said, Option 1 "@Override should be applied at //1" is not correct, because if I know that this will cause compilation error (option 2), than why should I do it? I literally saw that the contract for equals method was wrong, and I know the code will not compile with @Override, so why should I do it? When there's a option that clearly says "there is no need to apply"?
If this question had only 1 right option to select, it would be okay, because Option 2 is the only the really makes sense.
-
- Site Admin
- Posts: 10152
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3382 :
Based on multiple feedback received above, we have changed the question to clearly say in the problem statement that the developer intends to override the equals method of the Object class in A.
Hope that will remove any ambiguity.
thank you for your feedback!
Hope that will remove any ambiguity.
thank you for your feedback!
If you like our products and services, please help us by posting your review here.
-
- Site Admin
- Posts: 10152
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3382 :
So,
OLD: Given the following class which intends to customize the logic for equals method:
NEW: Given the following class in which the developer intends to override the equals method of the Object class:
OLD: Given the following class which intends to customize the logic for equals method:
NEW: Given the following class in which the developer intends to override the equals method of the Object class:
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 10 guests