Please respond with a minimum of at least 150 words
Sorting exceptions into two categories (namely “unchecked” and “checked” exceptions) can significantly change how we handle exceptions within our program.
Checked exceptions are exceptions that occur at compile-time. These exceptions occur due to factors or events that are outside of our program’s immediate control–such as network issues, Input/Output device issues, files not being found when called, etc. Checked exceptions must either be dealt with inside of the method in which they are thrown, or else they must be passed up to an exception handler in higher-up method (by adding a “throws” clause in the method’s argument parameter).
Because of this ability to pass the exception to another method, these types of exceptions have the potential to be ignored or “swallowed” (as some of the material has dubbed), although this is not recommended of course. These exceptions should be dealt with in some way within our program wherever absolutely possible utilizing try-catch blocks or try-catch-finally blocks.
Unchecked exceptions are exceptions that occur at run-time. These consist of exceptions that deal with issues within our actual program code (or possible issues due to the user’s interaction with our code). Examples of these would be trying to access an element outside of a specified array, attempting to divide a number by 0, or a user attempting to input a letter or string into an input box designed to accept an integer.
These types of exceptions are dealt with on an “as-needed” basis, one might could say, as they attempt to catch specific errors that can spring up from the execution of buggy code. Thoroughly testing our code and being aware of the different types of exceptions that could occur within our code (and then properly handling them) can keep our code functioning smoothly and efficiently.
When it comes to which method I would prefer:
The geeksforgeeks.com website reads that throwing checked exceptions may be a better option if the user has a decent amount of control over recovering from the exceptions, and if not, unchecked exceptions are better used. It also appears that checked exceptions can allow for more robust code, although (as stated earlier), this does give programmers the opportunity to pass the buck and not deal with certain exceptions simply because they do not want to be thorough. But I also found from my research that some languages (such as C#) do not have checked exceptions, and that language appears to work well without them.
Reflecting upon my researching of this subject, (and my limited experience utilizing exceptions in my own code in my last course), I feel as though I would be more inclined to utilize unchecked exceptions, when possible. I think it makes more sense to be able to address the exceptions as needed rather than “covering the entire code with ‘throws’ clauses” as the infoworld.com website puts it. Although, I am totally new to this realm, so I’m sure I’ll learn more as I go!
Thanks for reading, all and best of wishes in the module!
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.Read more
Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.Read more
Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.Read more
Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.Read more
By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.Read more