Exception Handling
© examsiri.com
Question : 21 of 24
Marks:
+1,
-0
Given:
And the following three possible changes:
C1. Declare that main() throws an Exception.
C2. Declare that Ping.getInt() throws an Exception.
C3. Wrap the invocation of getInt() in a try / catch block.
Which change(s) allow the code to compile? (Choose all that apply.)
1. class Ping extends Utils {
2.   public static void main(String [] args) {
3.    Utils u = new Ping();
4.    System.out.print(u.getInt(args[0]));
5.   }
6.   int getInt(String arg) {
7.    return Integer.parseInt(arg);
8.   }
9. }
10. class Utils {
11.   int getInt(String x) throws Exception { return 7; }
12. }And the following three possible changes:
C1. Declare that main() throws an Exception.
C2. Declare that Ping.getInt() throws an Exception.
C3. Wrap the invocation of getInt() in a try / catch block.
Which change(s) allow the code to compile? (Choose all that apply.)
Go to Question: