Question 743: What will be the output of the program?public class X { public static void main(String [] args) { try { badMethod(); System.out.print("A"); } catch (Exception ex) { System.out.print("B"); } finally { System.out.print("C"); } System.out.print("D"); } public static void badMethod() { throw new Error(); /* Line 22 */ } }
tcs
wipro
infosys
general
aptitude
exceptions
Erroris thrown but not recognised line(22) because the only catch attempts to catch anExceptionandExceptionis not a superclass ofError. Therefore only the code in thefinallystatement can be run before exiting with a runtime error (Exception in thread "main"java.lang.Error).