About Question enthuware.ocpjp.v11.2.3382 :

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

Moderator: admin

Post Reply
peterz
Posts: 6
Joined: Tue Jan 26, 2021 9:24 am
Contact:

About Question enthuware.ocpjp.v11.2.3382 :

Post 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?

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

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

Post 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.
If you like our products and services, please help us by posting your review here.

fortesp
Posts: 9
Joined: Mon Dec 14, 2020 8:53 am
Contact:

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

Post 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?

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

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

Post 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.
If you like our products and services, please help us by posting your review here.

fortesp
Posts: 9
Joined: Mon Dec 14, 2020 8:53 am
Contact:

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

Post 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.

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

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

Post 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!
If you like our products and services, please help us by posting your review here.

get4gopi
Posts: 2
Joined: Thu Apr 29, 2021 10:17 pm
Contact:

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

Post 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.

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

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

Post by admin »

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.

lxfusst
Posts: 2
Joined: Fri Aug 06, 2021 7:46 am
Contact:

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

Post by lxfusst »

Yeah.. It's super tricky.. 3 is way better than 1.

nishantingle
Posts: 1
Joined: Mon Oct 04, 2021 10:56 am
Contact:

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

Post by nishantingle »

Please change it from 1 to 3.

Low quality question.

gadsgadsx
Posts: 1
Joined: Fri Apr 12, 2024 11:09 pm
Contact:

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

Post 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.

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

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

Post 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!
If you like our products and services, please help us by posting your review here.

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

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

Post 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:
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 35 guests