About Question enthuware.ocpjp.v8.2.1098 :

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

Moderator: admin

Post Reply
badbishop
Posts: 27
Joined: Fri Jul 22, 2016 9:14 am
Contact:

About Question enthuware.ocpjp.v8.2.1098 :

Post by badbishop »

In fact, all the answers are valid implementations, as they have no compilation issues.

The question should be rephrased to refer to suitability for usual equality establishment operations. Or, say, one could add @Override annotation to each possible answer.

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

Re: About Question enthuware.ocpjp.v8.2.1098 :

Post by admin »

This is as per the convention followed by the real exam. The real exam questions explicitly say "compiles correctly" or "runs without exception" when they refer to compilation or runtime issues. It doesn't use the word "valid" for compilation or execution. It uses this word for when the code is inappropriate for some or the other reason.

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

shamran99
Posts: 15
Joined: Wed May 10, 2017 2:49 am
Contact:

Re: About Question enthuware.ocpjp.v8.2.1098 :

Post by shamran99 »

Hi,

Please explain the bolded part. Thanks!

It is consistent: for any reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the object is modified.

Regards,
Shamran

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

Re: About Question enthuware.ocpjp.v8.2.1098 :

Post by admin »

If you modify the value of any field that is used in the equals method to compare, then the value returned by equals may change. For example, if your equals method compares an int instance variable of two objects then if you change the value of that int variable of one object then equals may return a different value.
If you like our products and services, please help us by posting your review here.

shamran99
Posts: 15
Joined: Wed May 10, 2017 2:49 am
Contact:

Re: About Question enthuware.ocpjp.v8.2.1098 :

Post by shamran99 »

Thanks!

bvrulez
Posts: 33
Joined: Sat Feb 15, 2020 12:44 am
Contact:

Re: About Question enthuware.ocpjp.v8.2.1098 :

Post by bvrulez »

I don't want to criticize the question and answers but I wanted to check if I understand it right that in this (correct) case the equals method returns true just in this one case that the two references are pointing to the same object.

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

Re: About Question enthuware.ocpjp.v8.2.1098 :

Post by admin »

That's right.
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 28 guests