Oracle
1Z0-804 · Question #157
Given the code fragment: try { String query = "SELECT * FROM Employee WHERE ID=110"; Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(query); // Line 13…
The correct answer is B. The code prints the employee ID. See the full explanation below for the reasoning.
Question
Given the code fragment:
try { String query = "SELECT * FROM Employee WHERE ID=110"; Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(query); // Line 13 System.out.println("Employee ID: " + rs.getInt("ID")); // Line 14 } catch (Exception se) { System.out.println("Error"); } Assume that the SQL query matches one record. What is the result of compiling and executing this code?
Options
- AThe code prints error.
- BThe code prints the employee ID.
- CCompilation fails due to an error at line 13.
- DCompilation fails due to an error at line 14.
How the community answered
(47 responses)- A2% (1)
- B83% (39)
- C11% (5)
- D4% (2)
Community Discussion
No community discussion yet for this question.