Given:
1. public class Main { 2. // insert code here 3. int x = 0; 4. System.out.println(7/x); 5. } 6. }
And given the following four code fragments:
I. public static void main(String[] args) { II. public static void main(String[] args) throws Exception { III. public static void main(String[] args) throws IOException { IV. public static void main(String[] args) throws RuntimeException {
If the four fragments are inserted independently at line 2, which are true?
Choose all that apply.
D is correct.
A, B, and C are incorrect.
To throw an IOException, you have to import the java.io package or declare the exception with a fully qualified name.
E is incorrect because it's okay both to handle and declare an exception.