hi folks -
been studying from the book "Sun Certified Programmer for
Java 2 Study Guide (Exam 310-025)",
Second Edition, Copyright 2001 by The McGraw-Hill Companies. here's some code with accompanying review question found on page 210:
the answer is that the program does not compile due to error on line 13 which is the line where we find "out.close()" in the finally section.
The book says "any method that throws a checked exception must be called within a try clause or the method must declare that it throws the exception.
SO, HOW WOULD YOU HANDLE CODING OF THE "out.close()" call?
a) place the code within a new try-catch block within the finally {}?
b) other ideas?
Note: earlier in the review part for this section, the authors specifically stated "This is the right place to close files, release your network sockets, and perform any other cleanup your code requires". Funny how the
test review question seems to disprove that statement!
THANKS