Java OCA OCP Practice Question 2928

Question

In the table animal with 10 rows, how many times does true get output by the following?

Choose all that apply.

String sql = "select * from animal"; 
try (Connection conn = DriverManager.getConnection("jdbc:derby:zoo"); 
     Statement stmt = conn.createStatement( 
          ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); 

   ResultSet rs = stmt.executeQuery(sql)); 
   System.out.println(rs.beforeFirst()); 
   System.out.println(rs.absolute(5)); 
   System.out.println(rs.previous()); 
   System.out.println(rs.relative(-2)); 
   System.out.println(rs.afterLast()); 
  • A. One
  • B. Two
  • C. Three
  • D. Four
  • E. Five
  • F. The code does not compile.
  • G. A SQLException is thrown.


F.

Note

The first and last println statements do not compile.

The beforeFirst() and afterLast() methods have a void return type.

Therefore, the code does not compile and choice F is correct.




PreviousNext

Related