About Question enthuware.ocpjp.v7.2.1451 :

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

Moderator: admin

Post Reply
alkour
Posts: 30
Joined: Tue Mar 24, 2015 2:59 pm
Contact:

About Question enthuware.ocpjp.v7.2.1451 :

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

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

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

Post by admin »

Yes, it is the right option.

timwaagh
Posts: 6
Joined: Mon Sep 16, 2019 4:11 am
Contact:

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

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

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

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

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

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 7 guests