Please explain as far as possible the following lines of code marked with the .
ID: 3607429 • Letter: P
Question
Please explain as far as possible the following lines of code marked with the . You can refer to the handout. publie static void main(Stringl args) throws 1OException" Try File fo new File"friends.bin) FileInputStream fis = new FileInputStream(f); DataInputStream dis new DataInputStream(fis); // lines of code here //end try catch (EOFException ex) System.out.println InEnd of File); //end catch eof catch (IOException ex)* System.out printlnC There is an exception" + ex.toSt //end catch ioexceptionExplanation / Answer
The first line is the method declaration which says that the method can throw IOException when called.
The second line 'Try' initialises a try block, the statements from that block can throw any exceptions which are catched by the catch blocks defined on the third and fourth lines marked with '*'.
The third line catches any 'EOFException'
The fourth line catches any 'IOException'