About Question enthuware.ocajp.i.v7.2.842 :
Moderator: admin
Online
-
- Site Admin
- Posts: 10170
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.842 :
Updated.
thank you for your feedback!
thank you for your feedback!
If you like our products and services, please help us by posting your review here.
-
- Posts: 3
- Joined: Thu Dec 23, 2021 5:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.842 :
Please define "flow control". (https://en.wikipedia.org/wiki/Flow_control_(data) in the context of a programming language.Use flow control to terminate the loop
Did you mean "control flow statements"?
Online
-
- Site Admin
- Posts: 10170
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.842 :
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!
thank you for your feedback!
If you like our products and services, please help us by posting your review here.
-
- Posts: 24
- Joined: Wed Sep 28, 2022 9:41 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.842 :
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".
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".
Online
-
- Site Admin
- Posts: 10170
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.842 :
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.
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.
-
- Posts: 8
- Joined: Tue Sep 19, 2023 12:11 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.842 :
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?
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?
Online
-
- Site Admin
- Posts: 10170
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.842 :
Thank you for your feedback. Will enhance.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: admin and 2 guests