Sunteți pe pagina 1din 2

Name: Block : Time: Assigment

1. Modify the following cat method so that it will compile.


public static void cat(File file) { RandomAccessFile input = null; String line = null; try { input = new RandomAccessFile(file, "r"); while ((line = input.readLine()) != null) { System.out.println(line); } return; } finally { if (input != null) { input.close(); } }

Give the output produced by the following code snippets. 1. int n =5; try { n =n/0; } catch (ArithmeticException error) { System.out.println(Arithmetic Exception Caught); } catch (NumberFormatException error) { System.out.println(Number Format Exception); } finally

{ System.out.print (Done); }

2. int n =5; try { N = n/0; } catch (Exception error) { System.out.println (Exception Caught); } finally { System.out.print (Done); }

S-ar putea să vă placă și