Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CIS 265 Summer 2018-Qui Name:rsh inor e csuID: 142358 Given the lav a program be

ID: 3915776 • Letter: C

Question

CIS 265 Summer 2018-Qui Name:rsh inor e csuID: 142358 Given the lav a program below, please write xception extends Eogion pablic class onert public Othert System.autpintn Showe pablik class Qaks public static wod mainShr ingl r try calerO 1catch lOtherException ex) System.out.prntin"Beach Tie public statik void callerl) throws OtherException System.out printin Surny" String str "Beach Time throw new Other Exceptionl'Thundersiorm System.out.printinl"loodingl Output line1: Output line2: Output line3:

Explanation / Answer

--> output line1 Sunny

--> output line2 Shower

--> output line3 Beach Time

Reason:--> The main() function call the static method caller() inside try block.

In the first line, it prints the "Sunny" and goes to next line. In next line if condition becomes true so it throws the OtherException and calls the constructor of OtherException class and print the message "Shower" in next line (Which is output 2) and since the try block throwing the OtherException So it goes to catch block and print the "Beach Time " in line 3.

In case, If condition of Caller() function becomes false, It will not throw an exception and catch block will not be executed.

thanks................

If you need any help regarding this solution, Please leave a comment.....................