Examine:
Which statement is true?
Examine:
Which statement is true?
B
To test: class E1 extends Exception { } class E2 extends RuntimeException { } public class App { public void m1() { System.out.println("m1.Accessed."); throw new E1(); } public void m2() { System.out.println("m2.Accessed."); throw new E2(); } public static void main(String[] args) { int level = 1; App obj = new App(); if (level <= 5 && level >= 3) { obj.m1(); } else { obj.m2(); } } }
The correct answer is the letter B, in cases of EXCEPTIONS you need to declare in the constructor "throws E1". In the case of a RuntimeException you don't need to.