About Question enthuware.ocpjp.v8.2.1098 :
Moderator: admin
-
- Posts: 27
- Joined: Fri Jul 22, 2016 9:14 am
- Contact:
About Question enthuware.ocpjp.v8.2.1098 :
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.
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.
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1098 :
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.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 15
- Joined: Wed May 10, 2017 2:49 am
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1098 :
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
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
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1098 :
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.
-
- Posts: 15
- Joined: Wed May 10, 2017 2:49 am
- Contact:
-
- Posts: 33
- Joined: Sat Feb 15, 2020 12:44 am
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1098 :
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.
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1098 :
That's right.
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 28 guests