QUESTION 6: Advanced Java Programming (a) Analyse the following Java code segment and answer the questions that follow: 1| public void methodA(File myfile) 2 { try(Scanner txtin = new Scanner(myfile))...


Hi please assist


please verify each line


QUESTION 6: Advanced Java Programming<br>(a) Analyse the following Java code segment and answer the questions that follow:<br>1| public void methodA(File myfile)<br>2 {<br>try(Scanner txtin = new Scanner(myfile))<br>{<br>/* read from file */<br>}<br>catch(FileNotFoundException e) { /* Handle missing file */}<br>8}<br>3<br>6<br>9<br>10 public void methodB(File myfile)<br>11 {<br>if (!myfile.exists()) { /* Handle missing file */ }<br>else<br>12<br>13<br>{<br>Scanner txtin = new Scanner (myfile);<br>/* read from file */<br>}<br>18}<br>14<br>15<br>16<br>17<br>i. Is FileNotFoundException a checked exception?<br>ii. Which method (methodA or methodB) is the correct way to process a potential FileN-<br>otFoundException? Provide a reason why you would this method.<br>

Extracted text: QUESTION 6: Advanced Java Programming (a) Analyse the following Java code segment and answer the questions that follow: 1| public void methodA(File myfile) 2 { try(Scanner txtin = new Scanner(myfile)) { /* read from file */ } catch(FileNotFoundException e) { /* Handle missing file */} 8} 3 6 9 10 public void methodB(File myfile) 11 { if (!myfile.exists()) { /* Handle missing file */ } else 12 13 { Scanner txtin = new Scanner (myfile); /* read from file */ } 18} 14 15 16 17 i. Is FileNotFoundException a checked exception? ii. Which method (methodA or methodB) is the correct way to process a potential FileN- otFoundException? Provide a reason why you would this method.

Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here