1z0-809 Exam Question 41

Given the code fragment:
9. Connection conn = DriveManager.getConnection(dbURL, userName, passWord);
10. String query = "SELECT id FROM Employee";
11. try (Statement stmt = conn.createStatement()) {
12. ResultSet rs = stmt.executeQuery(query);
13. stmt.executeQuery("SELECT id FROM Customer");
14. while (rs.next()) {
15. //process the results
16. System.out.println("Employee ID: "+ rs.getInt("id"));
17. }
18. } catch (Exception e) {
19. System.out.println ("Error");
20. }
Assume that:
The required database driver is configured in the classpath.
The appropriate database is accessible with the dbURL, userName, and passWord exists.
The Employee and Customer tables are available and each table has id column with a few records and the SQL queries are valid.
What is the result of compiling and executing this code fragment?
  • 1z0-809 Exam Question 42

    What is the proper way to defined a method that take two int values and returns their sum as an int value?
  • 1z0-809 Exam Question 43

    Given:
    final class Folder { //line n1
    / /line n2
    public void open () {
    System.out.print("Open");
    }
    }
    public class Test {
    public static void main (String [] args) throws Exception {
    try (Folder f = new Folder()) {
    f.open();
    }
    }
    }
    Which two modifications enable the code to print Open Close?
  • 1z0-809 Exam Question 44

    Given the code fragment:
    9. Connection conn = DriveManager.getConnection(dbURL, userName, passWord);
    10. String query = "SELECT id FROM Employee";
    11. try (Statement stmt = conn.createStatement()) {
    12. ResultSet rs = stmt.executeQuery(query);
    13.stmt.executeQuery("SELECT id FROM Customer");
    14. while (rs.next()) {
    15. //process the results
    16.System.out.println("Employee ID: "+ rs.getInt("id"));
    17.}
    18. } catch (Exception e) {
    19. System.out.println ("Error");
    20. }
    Assume that:
    The required database driver is configured in the classpath.
    The appropriate database is accessible with the dbURL, userName, and passWord exists.
    The Employee and Customer tables are available and each table has id column with a few records and the SQL
    queries are valid.
    What is the result of compiling and executing this code fragment?
  • 1z0-809 Exam Question 45

    Given:

    What is the result?