Question: java program Problem 5 [6 points] Consider the following program that uses exceptions. Note: MyException andFileiotFoundException are both subclasses of IOException: public class MyProg i

java program

java program Problem 5 [6 points] Consider the following program that uses

Problem 5 [6 points] Consider the following program that uses exceptions. Note: MyException andFileiotFoundException are both subclasses of IOException: public class MyProg i public static void main (String args) ArrayList lines readFile(); if (lines.get(i).length ( } > mxSoFar) maxSo Far = ines.get(s).length(); { ystem.out println ("Max line isax3oFar) catch (MyException exc) { System . out .printin ("Error #1"); catch (IOEception ex System . out .printin ("Error #2"); public static ArrayList readEile throws IOEnception ArrayList lines = new ArrayList(); try i Scanner inFile new Scanner (new File ( "input Data")) ; if (inFile.hasNext)) throw new MyException) while (inFile.hasNentLine)) lines.ada (inFile.nentLine)) catch (EileNotFoundException exc) System . out . println ("Error #2"); return lines What is the output of the program for each of the following scenarios (show your answer to the right of each): 1. The file inputData is empty 2. The file inputDathas the contents: the elephant to the zoo today 3. The file inputData does not exist

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!