CIW
1D0-441 · Question #36
Consider the following code fragment: 1. PreparedStatement ps = conn.prepareStatement( 2. SELECT * FROM Orders WHERE + 3. Customer_No = ?); 4. 5. ps.setShort(0, 1001) 6. 7. ResultSet rs =…
The correct answer is D. No output is generated because a runtime error occurs at line 5. See the full explanation below for the reasoning.
Question
Consider the following code fragment: 1. PreparedStatement ps = conn.prepareStatement( 2. SELECT * FROM Orders WHERE + 3. Customer_No = ?); 4. 5. ps.setShort(0, 1001) 6. 7. ResultSet rs = ps.executeQuery(); 8. while(rs.next()) 9. { 10. System.out.print(rs.getString(1) + ); 11. System.out.println(rs.getString(2)); 12. } Assume that variable conn references a valid and open Connection object to a database containing the Orders Relation (shown in the exhibit). Which output is generated?
Exhibit
Options
- A2001 11-04-01
- B2001 11-04-01
- C11-04-01 1001
- DNo output is generated because a runtime error occurs at line 5.
How the community answered
(24 responses)- A4% (1)
- B4% (1)
- C8% (2)
- D83% (20)
Community Discussion
No community discussion yet for this question.
