Independence Day Deal! Unlock 25% OFF Today – Limited-Time Offer - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Oracle Exam 1Z0-809 Topic 2 Question 64 Discussion

Actual exam question for Oracle's 1Z0-809 exam
Question #: 64
Topic #: 2
[All 1Z0-809 Questions]

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?

Show Suggested Answer Hide Answer
Suggested Answer: A

Contribute your Thoughts:

Edmond
1 months ago
I bet this question was written by someone who still uses floppy disks. Seriously, who cares about compilation errors these days? Just let the JVM handle it!
upvoted 0 times
...
Coletta
1 months ago
Compilation fails on line 13? This guy must be living in the Stone Age. Java 7 introduced try-with-resources, which handles resource cleanup automatically.
upvoted 0 times
Verlene
7 days ago
No need to worry about compilation errors on line 13 with try-with-resources.
upvoted 0 times
...
Maile
9 days ago
Yeah, the try-with-resources should handle the resource cleanup automatically.
upvoted 0 times
...
Felton
20 days ago
I think the program prints employee IDs.
upvoted 0 times
...
...
Layla
2 months ago
No way, the program prints Error. The code is trying to execute two queries in the same try-with-resources block, which will result in an exception.
upvoted 0 times
Florinda
4 days ago
C) The program prints Error.
upvoted 0 times
...
Elina
17 days ago
B) The program prints customer IDs.
upvoted 0 times
...
Wei
1 months ago
A) The program prints employee IDs.
upvoted 0 times
...
...
Lorean
2 months ago
I think the program prints customer IDs. The code executes the query 'SELECT id FROM Customer' after processing the employee IDs.
upvoted 0 times
Amie
6 days ago
Oh, I see. I misunderstood the code fragment.
upvoted 0 times
...
Annelle
7 days ago
No, it actually prints employee IDs.
upvoted 0 times
...
Evangelina
8 days ago
I think the program prints customer IDs.
upvoted 0 times
...
...
Malcom
2 months ago
The program prints employee IDs. The code first executes the query 'SELECT id FROM Employee' and processes the results, which is what the question is asking about.
upvoted 0 times
...
Estrella
2 months ago
I believe the correct answer is A) The program prints employee IDs.
upvoted 0 times
...
Gail
2 months ago
I agree with Gregoria, the code is querying the Employee table.
upvoted 0 times
...
Gregoria
3 months ago
I think the program will print employee IDs.
upvoted 0 times
...

Save Cancel
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77