About Question com.enthuware.ets.scjp.v6.2.522 :

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

Moderator: admin

Post Reply
piotrkmiotczyk
Posts: 27
Joined: Mon Sep 22, 2014 1:30 pm
Contact:

About Question com.enthuware.ets.scjp.v6.2.522 :

Post by piotrkmiotczyk »

If passed a null it can also throw a NullPointerException, right? E.g.:

TestClass tc2 = null;
System.out.println(tc2.equals(null)); //does not return false, but throws NPE

(I picked answer "none of the above" instead of answer "must return false" because of this).

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

Re: About Question com.enthuware.ets.scjp.v6.2.522 :

Post by admin »

No, as per the requirements of the equals method, you pass a null, it should return false and not throw NPE. If a class throws NPE, then it is not an appropriate implementation of equals method.

HTH,
Paul.

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests