CIW Exam Questions

Which of the following Java code segments creates a prepared statement that could be used to produce

Refer to the exhibit to answer the question.

Consider the Products relation defined in the exhibit. Which of the following Java code segments
creates a prepared statement that could be used to produce a result set containing all of the
products that cost more than $2.00 and are priced less than $20 assuming con references a valid
and open Connection object?

A.
PreparedStatement ps = con.createStatement(
“SELECT * FROM Products WHERE ” +
“Cost > ? AND Price < ?”);

B.
PreparedStatement ps = con.preparedStatement(
“SELECT * FROM Products WHERE ” +
“Cost > ? AND Price < ?”);

C.
PreparedStatement ps = new PreparedStatement(
“SELECT * FROM Products WHERE ” +
“Cost > ? AND Price < ?”);

D.
PreparedStatement ps = con.prepareCall(
“SELECT * FROM Products WHERE ” +
“Cost > ? AND Price < ?”);

E.
PreparedStatement ps = con.prepareStatement(
“SELECT * FROM Products WHERE ” +
“Cost > ? AND Price < ?”);