Presuming all required import statements are in place, which lines of the following code will cause a compilation error?

1: class A {
2:    void m1() {throw new ArithmeticException();}
3:    void m2() {throw new ClassCastException();}
4:    void m3() {throw new IllegalArgumentException();}
5:    void m4() {throw new IndexOutOfBoundsException();}
6:    void m5() {throw new NullPointerException();}
7:    void m6() {throw new SecurityException();}
8: }
All listed exceptions extend "RuntimeException" class, hence all of them are Unchecked Exceptions. They can be declared in the method signature (using throws) but this is not required for compilation.

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Продовжуйте вивчати
тести з Java
Зареєструйся Зараз
або Підпишись на майбутні тести