Oracle Certified Professional Java Se 8 Programmer · Free Practice Question Hard

Question 10

Given structure of EMPLOYEE table: 

EMPLOYEE (ID integer, FIRSTNAME varchar(100), LASTNAME varchar(100), SALARY real, PRIMARY KEY (ID)) 


EMPLOYEE table contains below records: 


Given code of Test.java file: 


Also assume: 
URL, username and password are correct.
SQL query is correct and valid.
The JDBC 4.2 driver jar is configured in the classpath.

What will be the result of compiling and executing Test class? 

  • A

    13000.0
    16000.0
    16500.0
    15600.0

  • B

    12000.0
    15000.0
    15500.0
    15600.0

  • C

    12000.0
    15000.0
    15500.0
    14600.0

  • D

    15600.0
    16500.0
    16000.0
    13000.0

  • E

    13000.0
    15000.0
    15500.0
    14600.0

Reveal correct answer

Correct answer: A

Explanation

Given query returns below records:

101 John Smith 12000   

102 Sean Smith 15000   

103 Regina Williams 15500   

104 Natasha George 14600   


'rs.afterLast();' moves the cursor just after the last record. 


'rs.previous()' inside while loop moves the cursor from last to first and the codes inside while loop increment the salary of each record by 1000. 


'rs.updateRow();' makes sure that salary is updated in the database.


Next while loop simply prints the updated salaries on to the console.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need