exam questions

Exam 1z0-809 All Questions

View all questions & answers for the 1z0-809 exam

Exam 1z0-809 topic 1 question 171 discussion

Actual exam question from Oracle's 1z0-809
Question #: 171
Topic #: 1
[All 1z0-809 Questions]

Given records from the Player table:
and given the code fragment: try {
Connection conn = DriverManager.getConnection(URL, username, password);
Statement st= conn.createStatement(
ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
st.execute ("SELECT * FROM Player");
st.setMaxRows(2);
ResultSet rs = st.getResultSet();
rs.absolute(3);
while (rs.next ()) {
System.out.println(rs.getInt(1) + " " + rs.getString(2));
}
} catch (SQLException ex) {
System.out.print("SQLException is thrown.");
}
Assume that:
The required database driver is configured in the classpath.
The appropriate database is accessible with URL, username, and password.
The SQL query is valid.
What is the result?

  • A. 2 Jack 3 Sam
  • B. The program prints nothing.
  • C. 3 Sam
  • D. SQLException is thrown.
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
jduarte
Highly Voted 4 years, 4 months ago
Answer D. Tested. rs.absolute(3); move to the rows 3 and no exist
upvoted 10 times
...
6c84cb9
Most Recent 9 months, 2 weeks ago
B - (no output) - beacuse: The code attempts to move to a row that doesn't exist in the limited result set. Therefore, it results in no output being printed to the console. If there is an error due to the cursor being out of bounds, it might throw an SQLException, but based on standard JDBC behavior, it just results in no output.
upvoted 1 times
...
DarGrin
1 year ago
Selected Answer: B
Answer is B. The program prints nothing. rs.absolute(3) moves the cursor to the 3.row. And then rs.next() moves the cursor to the 4.row, which does'n exist
upvoted 1 times
...
shivkumarx
1 year, 2 months ago
Selected Answer: B
Answer is B, no exception was thrown
upvoted 1 times
...
iSnover
1 year, 4 months ago
Selected Answer: D
Answer D. Tested. rs.absolute(3); move to the rows 3 and no exist
upvoted 1 times
...
steefaand
1 year, 4 months ago
Selected Answer: B
It should be B as rs.absolute(3) will just return false and it shouldn't throw exception.
upvoted 1 times
...
Huim
4 years, 1 month ago
Answer ist B.
upvoted 2 times
...
Huim
4 years, 1 month ago
Answer is B. Prints nothing.
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...