In a table animal with 10 rows, how many times does true get output by the following? (Choose all that apply.)
F. The code does not compile.
G. A SQLException is thrown.
The book says answer C is the correct answer.
One could argue that it doesn't compile, because there's no closing }.
Anyway, could G also be a correct answer? When the driver doesn't support TYPE_SCROLL_INSENSITIVE and it downgrades to TYPE_FORWARD_ONLY, then rs.absolute(0) would throw a SQLException, right?
Or when Derby isn't on the classpath.
Or when the connection to the database suddenly drops.
The exam says that if you see a code snippet, you have to assume the surrounding code is right. So the missing } can be assumed.
G is more interesting. The exam lives in a perfect world. Drivers are always available and connections don't drop. (Although to be fair, an embedded database connection isn't getting a network error). Unless it is mentioned, you should assume the driver supports the required operation as well. But yes, G would happen in that scenario.
I mention this because real life JDBC experience actually makes this part of the exam harder. It was my "weakest" exam section even thought I've done plenty with JDBC> I had trouble thinking in that perfect world way. And I'm sure you saw our rant about that at the beginning of the chapter!