Oracle Certified Professional Java Se 11 Developer · Free Practice Question Hard

Question 100

Question ID: UKOCP44683


Given structure of MESSAGES table:

MESSAGES (msg1 varchar(100), msg2 varchar(100))


MESSAGES table contains below records:

'Happy New Year!', 'Happy Holidays!'


Given code of Test.java file:


Also assume:

URL is correct and db credentials are: root/password.

SQL query is correct and valid.

The JDBC 4.2 driver jar is configured in the classpath.


What is the result?

  • A 0
  • B 1
  • C Compilation error
  • D An exception is thrown at runtime
Reveal correct answer

Correct answer: C

Explanation

UKOCP44683:

Connection is an interface, hence new Connection(url, user, password); causes compilation error.


Correct way to create Connection object in this case will be: DriverManager.getConnection(url, user, password);

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need