Originally posted by Aru:
Hi all,
Given that a java.io.IOException might occur when calling the read() method of the BufferedInputStream, you can handle the exception by:
a) Listing a java.io.EOFException in a throws list.
b) Catch the java.lang.Exception using the throw statement.
c) Catch a java.io.EOFException using a try/catch clause.
d) Catch a java.lang.Exception using a try/catch 3
I think 1 & 3 should be the right choices....
Can anyone help....?
Thx in adv.
Aruna
I think the answer is d. only. EOFException is one of the subclasses of IOException, there are many more subclasses. Hence, it is not enough to catch it. java.lang.Exception, on the other hand, is parent of IOException, so IOException and all its children can be caught by this try/catch block.
Isn't that right?
Savithri