- 4

Finds 4 syntax errors in the following program:

class NewException extends Exception{ String str; public String toString(){ return ("MyException Occurred: "+str) ;} } class RethrowException2 { public static void methodC(){ System.out.println("After methodC"); throw new NewException(); System.out.println("After methodC"); } public static int methodB(){ try {methodC(); return 0; } catch(ArrayIndexOutOfBoundsException e) { throw e; System.out.println("In catch methodB"); } } public static void main(String[] args) { try {System.out.println(methodB()); } catch(NewException e) { System.out.println("In catch main "+ e);} } }

25th Apr 2020, 5:23 PM
Thikra
0 odpowiedzi