Question: Java !!!!!! The next four (4) questions are related. They deal with the following declarations: public class Blunder extends Exception { public Blunder(String message) {
Java !!!!!!
The next four (4) questions are related. They deal with the following declarations:
public class Blunder extends Exception { public Blunder(String message) { super(message); } } The method tally may raise a Blunder runtime error. Examine the following code:
public int getCount() { return gatherer.tally(); } 1. This code will not compile. Why? (Assume that gatherer exists and the call to tally is valid.)
Here are two suggestions for rewriting getCount. When you rewrite both, you may omit comments.
2. Option 1: Rewrite the method so that the error propagates back to the caller.
3. Option 2: Rewrite the method so that it outputs an error message and returns the value 1.
4. Compare Option 1 and Option 2, commenting on their relative merits, that is, say which option is better and why. (2 5 sentences)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
