About Question enthuware.ocpjp.v7.2.1399 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
Svetopolk
Posts: 22
Joined: Sun Nov 18, 2012 1:51 am
Contact:

About Question enthuware.ocpjp.v7.2.1399 :

Post by Svetopolk »

Case 2: This code will not work in all situations
Explanation: It will not work if assertions are disabled.

Why? I don't know for sure what the code does.
Probably it only prints PhoneNumber. And it will work even number==null or length() != 10

Or we can assume that the code really doesn't work properly if number==null. But it doesn't work in any circumstances: NPE or AssertionError - not a big deal.

I think we can't predict how ON/OFF assertion will influence on.

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

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

Post by admin »

Well, the problem statement says what the programmer wants to achieve, "...to ensure that the phone number is not null and is of 10 characters". It also shows the code that the programmer has written so you know what the code does.

The code will work fine if assertions are enabled but it will not do what is expected if assertions are disabled.

HTH,
Paul.

toolforger
Posts: 38
Joined: Fri Nov 13, 2015 4:40 am
Contact:

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

Post by toolforger »

Typo: Last option is "Constraints on input parameters should be enforced using assersions."
Last word should be "assertions".

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

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

Post by admin »

Fixed.
thank you for your feedback!

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests