Define the exceptions such that the program compiles - Java Quiz Question



Define the exceptions such that the program compiles and prints the output as shown below.

Input (Integer) Printed Output
1 Exception A occured with error code = 5
2 Exception B occured with difference = 1.23
3 Exception C occured with reason = Invalid Data

class DefineExceptions

{    public static void main(String s[])
    {
        process(1);

    }


public static void process(int input) {
try {
process2(input);
} catch (AEx ex) {
System.out.println("Exception A occured with error code = " + ex.errorCode);
} catch (BEx ex) {
System.out.println("Exception B occured with difference = " + ex.difference);
} catch (CEx ex) {
System.out.println("Exception C occured with reason = " + ex.reason);
}
}

public static void process2(int input) throws AEx, BEx, CEx {
if (input == 1) {
throw new AEx(5);
}
if (input == 2) {
throw new BEx(1.23);
}
if (input == 3) {
throw new CEx("Invalid Data");
}
}
}
//Define the exception classes such that the code compiles with out any errors