Given that FileNotFoundException extends IOException and given:
2. import java.io.*; 3. public class Main { 4. public static void main(String[] args) throws IOException { 5. new Main().go(); 6. new Main().go2(); 7. new Main().go3(); 8. } /*from ww w . j av a 2s . c om*/ 9. void go() { throw new IllegalArgumentException(); } 10. 11. void go2() throws FileNotFoundException { } 12. 13. void go3() { 14. try { throw new Exception(); } 15. catch (Throwable th) { throw new NullPointerException(); } 16. } }
What is the result? (Choose all that apply.)
C is correct.
It's legal for main()
to throw an exception, and it's legal to catch a checked exception and re-throw a runtime exception.