exam questions

Exam 1z0-809 All Questions

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

Exam 1z0-809 topic 1 question 29 discussion

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

Given the structure of the STUDENT table:
Student (id INTEGER, name VARCHAR)
Given:
public class Test {
static Connection newConnection =null;
public static Connection get DBConnection () throws SQLException { try (Connection con = DriveManager.getConnection(URL, username, password)) { newConnection = con;
}
return newConnection;
}
public static void main (String [] args) throws SQLException { get DBConnection ();
Statement st = newConnection.createStatement();
st.executeUpdate("INSERT INTO student VALUES (102, "˜Kelvin')");
}
}
Assume that:
The required database driver is configured in the classpath.
The appropriate database is accessible with the URL, userName, and passWord exists.
The SQL query is valid.
What is the result?

  • A. The program executes successfully and the STUDENT table is updated with one record.
  • B. The program executes successfully and the STUDENT table is NOT updated with any record.
  • C. A SQLException is thrown as runtime.
  • D. A NullPointerException is thrown as runtime.
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

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
adnano1234
Highly Voted 5 years ago
Answer is: ConnectionIsClosedException Try with resources has, as a result, closed the connection.
upvoted 8 times
...
DarGrin
Most Recent 8 months ago
Selected Answer: C
Answer is C, tested Exception in thread "main" java.sql.SQLNonTransientConnectionException: Connection is closed
upvoted 1 times
...
DarGrin
8 months, 2 weeks ago
Selected Answer: D
java.lang.NullPointerException , tested
upvoted 1 times
DarGrin
7 months, 4 weeks ago
sorry. answer is C
upvoted 1 times
...
...
steefaand
1 year ago
Selected Answer: C
C is correct since connection is not null but closed and SQLException is thrown.
upvoted 1 times
...
r1muka5
1 year, 10 months ago
Selected Answer: C
Correct answer is C.
upvoted 2 times
...
WilsonKKerll
2 years, 11 months ago
Answer : java.lang.NullPointerException
upvoted 1 times
...
mevlt
2 years, 11 months ago
The answer is A. Tested.
upvoted 1 times
...
Tarik2190
3 years, 9 months ago
Answer C: cannot be NullPointerException, since the object of connection is still there, it is just closed, which means SQLException
upvoted 4 times
...
Destroyer
5 years, 1 month ago
Answer is "A NullPointerException is thrown as runtime."
upvoted 1 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