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

Java Programming: Choose the answer for 1st, 2nd, and 3rd output. Thanks in adva

ID: 3747792 • Letter: J

Question

Java Programming: Choose the answer for 1st, 2nd, and 3rd output.
Thanks in advance.

Show the output produced by the program segment below, assuming.that the file datafile.txt exists and is opened successfully try System.out.println("Opening datafile.txt"); Scanner input new Scanner(new File("datafile.txt")); int number Integer.parseInt("not an integer"); System.out.println("Done"); catch (IOException exception) System.out.println("File not found"); catch (NumberFormatException exception) System.out.println("Integer not found"); catch (Exception exception) System.out.println("Not sure what happened"); 1st output line (select NONE if no output): 2nd output line (select NONE if no output): 3rd output line (select NONE if no output): ening datafile, Integer not fou NON Don Not sure what ha File not foun

Explanation / Answer

The first line of the output will be: Opening datafile.txt

(assuming file exists and opened correctly)

The second line of the output will be: Integer not found

(NumberFormatException will be thrown when we try to parse an integer from a non-numeric String)

The third line of the output will be: NONE

(There is no 3rd line for the output. The print statement System.out.println(“Done”); won’t get executed because of the Exception thrown by Integer.parseInt() before it)

Thanks, and let me know if you have any doubts.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote