Suppose the exception class MyException is defined as follows: public class MyException extends Exception { public MyException() { super("My Exception thrown!"); } public MyException(String...



Suppose the exception class MyException is defined as follows:


public class MyException extends Exception


{



public MyException()



{



super("My Exception thrown!");



}


public MyException(String message)



{



super("MyException: " + message);



}


}


What output would be produced by the following code (which is just an


exercise and not likely to occur in a program)?


int number;


try


{



System.out.println("try block entered:");



number = 42;



if (number > 0)



throw new MyException("Hi Mom!");



System.out.println("Leaving try block.");


}


catch(MyException exceptionObject)


{



System.out.println(exceptionObject.getMessage());


}


System.out.println("End of example.");


The class MyException is on the website that comes with this text.



May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here