About Question enthuware.ocajp.i.v7.2.842 :

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

Moderator: admin

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

Re: About Question enthuware.ocajp.i.v7.2.842 :

Post by admin »

Updated.
thank you for your feedback!
If you like our products and services, please help us by posting your review here.

ignore.your
Posts: 3
Joined: Thu Dec 23, 2021 5:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.842 :

Post by ignore.your »

Use flow control to terminate the loop
Please define "flow control". (https://en.wikipedia.org/wiki/Flow_control_(data) in the context of a programming language.

Did you mean "control flow statements"?

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

Re: About Question enthuware.ocajp.i.v7.2.842 :

Post by admin »

You are right. It should be control flow statements. The option statement has been updated to "Use control flow statements to terminate the loop."

thank you for your feedback!
If you like our products and services, please help us by posting your review here.

edufin166@yahoo.com
Posts: 24
Joined: Wed Sep 28, 2022 9:41 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.842 :

Post by edufin166@yahoo.com »

Im my oppinnion, the answer corret is "Use ArrayIndexOutOfBoundsException for the catch argument and add code in the catch block to log or print the exception".

Even though, the reason explained is that : "However, in this case, since the code is deliberaly written such a way that an exception will be thrown, the timing and cause of the exception are already known. Therefore, there is no need for logging the exception"

The question ask EXPLICITLY "best practices to improve this code".

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

Re: About Question enthuware.ocajp.i.v7.2.842 :

Post by admin »

It is indeed a good practice to log an exception at a minimum. But this practice is for exceptional situations. i.e. where you would want to check the logs if an exception is thrown so that you will have more information for fixing/improving the code. In the given situation, there is no such need because you know that the exception will be thrown, you know why that exception will be throw, and you want the exception to be thrown.

Best practices are not to be applied blindly. You need to understand why that practice is called a best practice and the reason for doing it.
If you like our products and services, please help us by posting your review here.

powerofviva
Posts: 8
Joined: Tue Sep 19, 2023 12:11 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.842 :

Post by powerofviva »

I really dont understand why the first answer is better than the second one.
It is always better to add the code in catch block and log it.
it is always bad practice to have empty catch block, how can here say just for the exam, the answer 1 is correct, but the second is not!

#1 is correct, but #2 is always best practice, maybe you should change the answer?

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

Re: About Question enthuware.ocajp.i.v7.2.842 :

Post by admin »

Thank you for your feedback. Will enhance.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 59 guests