Java SE 11 Developer (1Z0-819) — Question 103
Assuming the user credentials are correct, which expression will create a Connection?
Answer options
- A. DriverManager.getConnection("http://database.jdbc.com", "J_SMITH", "dt12%2f3")
- B. DriverManager.getConnection("jdbc:derby:com")
- C. DriverManager.getConnection("jdbc.derby.com")
- D. DriverManager.getConnection()
- E. DriverManager.getConnection("J_SMITH", "dt12%2f3")
Correct answer: B
Explanation
The correct answer is B because it uses the correct JDBC URL format for a Derby database connection. Option A is incorrect as it uses an HTTP URL, while C lacks the proper JDBC prefix. Option D does not provide any parameters, and E does not contain the required JDBC URL.