Question: Question 2 [5 marks] Given this class: class MTException extends Exception { } What is the output of the following program? class MT2Q2 { public
Question 2 [5 marks] Given this class: class MTException extends Exception { } What is the output of the following program? class MT2Q2 { public static void bar (int x) throws, MTException { System.out.println("Q"); if (x > 2) { throw new MTException(); } System.out.println("S"); } public static void foo (int x) throws MTException { System.out.println("T"); bar(); System.out.println("A"); } public static void main (String[] args) { try { System.out.println("D"); foo(8), System.out.println("F"); } catch (MTException e) { System.out.println(""); } System.out.println(""); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
