Question: Given the below code: public static void main(String[] args) { try { Scanner in = new Scanner(new FileInputStream(a.txt)); } } catch (FileNotFoundException e) {

Given the below code: public static void main(String[] args) { try {

Given the below code: public static void main(String[] args) { try { Scanner in = new Scanner(new FileInputStream("a.txt")); } } catch (FileNotFoundException e) { System.out.println("There is no such file! " + e.getMessage()); } catch (Exception e) { System.out.println("I am in exception handler"); throw new RuntimeException(e); } finally { } System.out.println("I am in finally"); (a) What is the output when there IS a file named a.txt? (b) What is the output when there is no file named a.txt?

Step by Step Solution

3.39 Rating (165 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

import javautilScanner import javaio class Main public static void mainString args try Scanner in ne... View full answer

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 Programming Questions!