nerdexam
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)
  • A
    2% (1)
  • B
    83% (39)
  • C
    11% (5)
  • D
    4% (2)

Community Discussion

No community discussion yet for this question.

Full 1Z0-804 Practice