Given:
2. public class Main { 3. public static void main(String[] args) { // change code here ? 4. // insert code here ? 5. new Main().doShape(); 6. // insert code here ? ... //from w ww.jav a 2 s . co m 10. } 11. static void doShape() throws Exception { 12. throw new Exception(); 13. } }
Which are true? (Choose all that apply.)
main()
is changed to throw an Exception.main()
declares an Exception AND a try-catch is added, surrounding line 5.B and C are correct.
Invoking doShape()
will cause an Exception that must either be handled (option C) or declared (option B).
(Remember, you can compile a program in which main()
throws an Exception.).
A is incorrect based on the above.
D is incorrect because a try-finally will not handle the Exception.
E is incorrect because EITHER handling or declaring the exception is sufficient.