exam questions

Exam 1z0-809 All Questions

View all questions & answers for the 1z0-809 exam

Exam 1z0-809 topic 1 question 172 discussion

Actual exam question from Oracle's 1z0-809
Question #: 172
Topic #: 1
[All 1z0-809 Questions]

Given:

Item table -
"¢ ID, INTEGER: PK
"¢ DESCRIP, VARCHAR(100)
"¢ PRICE, REAL
"¢ QUANTITY< INTEGER
And given the code fragment:
9. try {
10. Connection conn = DriveManager.getConnection(dbURL, username, password);
11. String query = "Select * FROM Item WHERE ID = 110";
12. Statement stmt = conn.createStatement();
13. ResultSet rs = stmt.executeQuery(query);
14. while(rs.next()) {
15. System.out.println("ID: " + rs.getString(1));
16. System.out.println("Description: " + rs.getString(2));
17. System.out.println("Price: " + rs.getString(3));
18. System.out.println(Quantity: " + rs.getString(4));
19. }
20. } catch (SQLException se) {
21. System.out.println("Error");
22. }
Assume that:
The required database driver is configured in the classpath.
The appropriate database is accessible with the dbURL, userName, and passWord exists.
The SQL query is valid.
What is the result?

  • A. An exception is thrown at runtime.
  • B. Compilation fails.
  • C. The code prints Error.
  • D. The code prints information about Item 110.
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
asdfjhfgjuaDCV
4 months, 3 weeks ago
D is the Correct answer
upvoted 1 times
...
steefaand
5 months, 3 weeks ago
Selected Answer: D
Answer is D as getString can be used to retrieve data of other types.
upvoted 1 times
...
iSnover
5 months, 3 weeks ago
Selected Answer: D
As column ID defined by INTEGER, but you can get it by getString("<column name>").
upvoted 1 times
...
duydn
10 months, 2 weeks ago
The answer is D. As column ID defined by INTEGER, but you can get it by getString("<column name>") line 18 I think is typo -> D
upvoted 1 times
...
WilsonKKerll
2 years, 4 months ago
Answer is d.
upvoted 1 times
...
mevlt
2 years, 4 months ago
Answer is D
upvoted 1 times
...
griglad
2 years, 5 months ago
Although the value of the ID field is int, it can still be retrieved using getString().
upvoted 2 times
...
PontPont
3 years, 1 month ago
15. System.out.println("ID: " + rs.getString(1));' ID is integer not string.
upvoted 3 times
...
jduarte
3 years, 6 months ago
Line 18 is missing a quotation mark. The correct answer is b
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago