An unchecked exception occurs in a method dosomething() Should other code be added in the dosomething() method for it to compile and execute?
Correct Answer: D
Because the Java programming language does not require methods to catch or to specify unchecked exceptions (RuntimeException, Error, and their subclasses), programmers may be tempted to write code that throws only unchecked exceptions or to make all their exception subclasses inherit from RuntimeException. Both of these shortcuts allow programmers to write code without bothering with compiler errors and without bothering to specify or to catch any exceptions. Although this may seem convenient to the programmer, it sidesteps the intent of the catch or specify requirement and can cause problems for others using your classes.
Question 87
Given the code fragment: Which three lines fail to compile? (Choose three.)