Card 27 / 54: 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 */ } }
A)
ABCD
B)
Compilation fails.
C)
C is printed before exiting with an error message.
D)
BC is printed before exiting with an error message.
Answer:
C) C is printed before exiting with an error message.
Previous Card | ← Previous Card Button |
Next Card | → Next Card Button |
Flip Card | Space-Bar |