Java OCA OCP Practice Question 2033

Question

Given the table books in the figure and a ResultSet created by running the following SQL statement, which option prints the value 379?.

title num_pages
character varying(255) integer
OCA3
OCP6

select * from cert where title = 'OCA'.

A.     System.out.println(rs.getInt(1));
B.    System.out.println(rs.getInt(2));
C.     System.out.println(rs.getInteger(1));
D.    System.out.println(rs.getInteger(2));


B.

Note

Unlike arrays, JDBC uses one-based indexes.

Since num_pages is in the second column, the parameter needs to be 2, ruling out Options A and C.

Further, there is not a method named getInteger() on the ResultSet interface, ruling out Option D.

Since the proper method is getInt(), Option B is the answer.




PreviousNext

Related