Page 1 of 1

About Question enthuware.ocpjp.v11.2.3382 :

Posted: Wed Jan 27, 2021 2:00 pm
by peterz
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?

Re: About Question enthuware.ocpjp.v11.2.3382 :

Posted: Wed Jan 27, 2021 9:56 pm
by admin
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.

Re: About Question enthuware.ocpjp.v11.2.3382 :

Posted: Tue Feb 09, 2021 8:28 am
by fortesp
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?

Re: About Question enthuware.ocpjp.v11.2.3382 :

Posted: Tue Feb 09, 2021 11:40 am
by admin
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.

Re: About Question enthuware.ocpjp.v11.2.3382 :

Posted: Wed Feb 10, 2021 3:16 am
by fortesp
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.

Re: About Question enthuware.ocpjp.v11.2.3382 :

Posted: Thu Feb 11, 2021 12:16 am
by admin
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!

Re: About Question enthuware.ocpjp.v11.2.3382 :

Posted: Thu Apr 29, 2021 10:27 pm
by get4gopi
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.

Re: About Question enthuware.ocpjp.v11.2.3382 :

Posted: Thu Apr 29, 2021 10:32 pm
by admin
Thank you for your feedback but in our view the question is fine. Please go through the discussion above.

Re: About Question enthuware.ocpjp.v11.2.3382 :

Posted: Sat Aug 07, 2021 10:41 am
by lxfusst
Yeah.. It's super tricky.. 3 is way better than 1.

Re: About Question enthuware.ocpjp.v11.2.3382 :

Posted: Mon Oct 04, 2021 10:58 am
by nishantingle
Please change it from 1 to 3.

Low quality question.

Re: About Question enthuware.ocpjp.v11.2.3382 :

Posted: Fri Apr 12, 2024 11:15 pm
by gadsgadsx
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.

Re: About Question enthuware.ocpjp.v11.2.3382 :

Posted: Sat Apr 13, 2024 12:09 am
by admin
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!

Re: About Question enthuware.ocpjp.v11.2.3382 :

Posted: Sat Apr 13, 2024 12:10 am
by admin
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: