Page 1 of 1

About Question enthuware.ocpjp.v8.2.1924 :

Posted: Mon Nov 05, 2018 6:57 pm
by MoistCarrot
Java docs state:
boolean absolute(int row) throws SQLException

Moves the cursor to the given row number in this ResultSet object.
Question states:
The call to rs.absolute() places the cursor right after the given row number if the argument is a positive integer.
The java doc says that it moves the cursor to the given row number. Which, in this case would be 5. With that being said, why does the explanation say that it places the cursor after the given row number?

Since there are only 5 rows of data, according to the java docs, the call to absolute(5) would place the cursor at 5. Then the subsequent call to rs.next() would return false, since there is nothing after 5. Thus we arrive at the answer that it will not print anything.

Please correct me if i'm wrong, and point out my mistakes. Otherwise, I believe the explanation should be changed to match the java docs, since it could be misleading if i'm correct.

Normally I would try to run the code on my system to test it out and analyze each line; however, I do not want to go through the trouble of setting up a dummy database, and running the code to test this question. Call me lazy I guess :lol:.

Re: About Question enthuware.ocpjp.v8.2.1924 :

Posted: Mon Nov 05, 2018 9:21 pm
by admin
You are right. The explanation is incorrect. It should says "right before" instead of "right after". The answer is still the same though, it will not print anything because of the call to rs.next().

This has now been fixed.

thank you for your feedback!

Re: About Question enthuware.ocpjp.v8.2.1924 :

Posted: Fri Jan 18, 2019 6:31 pm
by valix85
The correct answer is not compile on line one
"Connection c = DriverManager.getConnection("jdbc:derby://localhost:1527/sample", "app", "app");"
this method "getConnection()" throw a SQLException (checked) and this line is out of try-catch block

Re: About Question enthuware.ocpjp.v8.2.1924 :

Posted: Fri Jan 18, 2019 10:53 pm
by admin
For the purpose of the exam, if you see partial code listing, you need to assume that given code is present in an appropriate context. So, yes, even though this line is out of the try/catch shown in the code listing, the whole listing could be a part of a method with appropriate throws clause or there could be another try catch encompassing the whole listing. This is specially so, when "will not compile" is not even an option.