Page 1 of 1

About Question enthuware.ocpjp.v21.2.4040 :

Posted: Wed Sep 24, 2025 10:09 am
by giginar
the default one (option 3) is false because: "all the building subclasses(hotel, hospital) are covered, except for "null" case, so we need null, not default" is that true?

Re: About Question enthuware.ocpjp.v21.2.4040 :

Posted: Wed Sep 24, 2025 9:17 pm
by admin
No, did you read the explanation?
This is syntactically valid but does not implement the logic given in the problem statement. If b is null, this code will throw a NullPointerException while the code in the problem statement will not.
So default will work but not exactly as the logic given in the problem statement.