Page 1 of 1

About Question enthuware.ocpjp.v7.2.1451 :

Posted: Sun Aug 09, 2015 2:56 pm
by alkour
Hi,

What does means Option:
If passed a null, it should return false.
I assume it could be right answer, as
For any non-null reference value x, x.equals(null) should return false.

Re: About Question enthuware.ocpjp.v7.2.1451 :

Posted: Sun Aug 09, 2015 9:08 pm
by admin
Yes, it is the right option.

Re: About Question enthuware.ocpjp.v7.2.1451 :

Posted: Mon Nov 04, 2019 9:02 am
by timwaagh
'For any non-null reference value x, x.equals(null) should return false.' is what the explanation says. The reason i chose 'none of the above' was because i was thinking on what if the object it is called upon is null as well. Now that i am thinking of it, if x==null, x.equals(null) would throw a NullPointerException? is that what happens? Would you care to expand the explanation a bit to cover this case?

Re: About Question enthuware.ocpjp.v7.2.1451 :

Posted: Mon Nov 04, 2019 7:47 pm
by admin
As the explanation says, x.equals(null) should return false.
It will not throw NPE because you are not invoking any method on null.

You may try it out as well.