Java OCA OCP Practice Question 2292

Question

which two of the following statements are true regarding Statement and its derived types?.

  • A. Statement can handle sQl queries with IN, OUT, and INOUT parameters.
  • B. PreparedStatement is used to execute stored procedures.
  • C. You can get an instance of PreparedStatement by calling the preparedStatement() method in the Connection interface.
  • d. CallableStatement extends the PreparedStatement class; PreparedStatement in turn extends the Statement class.
  • e. the Statement interface and its derived interfaces implement the AutoCloseable interface, hence Statement objects can be used with the try-with-resources statement.


the correct options are C and e.

Note

You can get an instance of PreparedStatement by calling the preparedStatement() method in the Connection interface.

the Statement interface and its derived interfaces implement the AutoCloseable interface, so Statement objects can be used with the try-with-resources statement.

the other three options a , B, and d are incorrect for the following reasons: a : Statement objects can be used for sQl queries that have no parameters.

only a CallableStatement can handle IN, OUT, and INOUT parameters.

B: PreparedStatement is used for precompiled sQl statements.

the CallableStatement type is used for stored procedures.

D: CallableStatement implements the PreparedStatement interface.

PreparedStatement in turn implements the Statement interface.

Further, these three types are interfaces, not classes.




PreviousNext

Related