Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions

Question

a. Describe the encounter. What made it intercultural?

Answered: 1 week ago