Question: I need the answer within 15 minutes. 3. Write the output for the following Code Snippet. class CustomException extends Exception { int a, b; public
I need the answer within 15 minutes.


3. Write the output for the following Code Snippet. class CustomException extends Exception { int a, b; public CustomException(int a, int b) { this.a = a; this.b = b; } @Override public String toString() { return "CustomException is invoked on a = " + a + ", b = " + b; a public class Main { private static int func(int a, int b) throws CustomException { if ((a % 2 == 0) && (b $ 2 != 0)) { // a Is even, bis odd throw new CustomException(a, b); } return (a + b); 11 public static void main(String[] args) { int res; try { res = func(2, 2); System.out.println("res = " + res); res = func(3, 3); System.out.println("res + res); res = func(2, 3); System.out.println("res + res); func(3, 2); System.out.println("res + res); } catch (CustomException e) { System.out.println(e.toString()); 11 res Write the output when this code is executed
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
