About Question enthuware.ocpjp.v8.2.1924 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
MoistCarrot
Posts: 6
Joined: Fri Oct 26, 2018 9:18 pm
Contact:

About Question enthuware.ocpjp.v8.2.1924 :

Post 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:.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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!
If you like our products and services, please help us by posting your review here.

valix85
Posts: 1
Joined: Fri Jan 18, 2019 6:29 pm
Contact:

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

Post 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

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests