For the following situations, indicate whether it would be better to catch an exception, declare an exception, or throw an exception in the lower-level method. Explain your answer and show the code...


For the following situations, indicate whether it would be better to catch an exception, declare an exception, or throw an exception in the lower-level method. Explain your answer and show the code required for the lower-level method to do it.


a. A lower-level method contains a call to method readl i ne; the higher-level method that calls it contains a catch clause for class IOExcepti on.


b. A method contains a call to method readL i ne to enter a value that is passed as an argument to a lower-level method. The lower-level method's argument must be a positive number.


c. A lower-level method contains a call to method readl ine, but the higher-level method that calls it does not have a catch clause for class IOExcepti on.


d. A lower-level method reads a data string and converts it to type int. The higher-level method contains a catch clause for class NumberFormatException.


e. A lower-level method detects an unrecoverable error that is an unchecked exception.



Dec 14, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here