Tuesday, January 26, 2010

III. Each Question Carries 4 Mark.

1) i) By using exceptions to manage errors
ii) it helps to separate the error handling code from the regular code
iii) A java method can “duck” any exceptions thrown with in it.
a) Only i b) only ii c) all d) None

2) i) Runtime exception can occur any where in the program
ii) It includes arithmetical, pointer exceptions, indexing exceptions
iii) The cost of checking for runtime exceptions often exceeds the benefit of catching.
a) All b) only i c) i, iii d) None

3) i) Try block contains the code that might throw an exception
ii) If the code executes without throwing an exception skipped
iii) If exception occurs then it goes to catch block
a) only i b) only ii c) All d) None


4) class WriteFile {PrintWriter p=new PrintWriter(new FileWriter(“a.txt”));
p.println(“hello world “);
p.close();
}

The above example may be raised an exception is
a) Arthmetical Exception b) NullPointer Exception c) IO Exception d) None

5) Exception handling provides the following features
i) Notify the user of an error
ii) Save the work environment
iii) Allowing to exit from the program without adversely affecting the other program execution.

a) Only i b) only i, ii c) All d) None

III. Answer – 4 Mark.


1.C 2. A 3. C 4. C 5. C