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

Question 82

Question ID: UKOCP47710


Given structure of LOG table:

LOG (ID integer, MESSAGE varchar(1000), PRIMARY KEY (ID))


LOG table contains below records:


Given code of Test.java file:


What is the result?

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

Correct answer: F

Explanation

UKOCP47710:

DriverManager.getConnection(...), con.createStatement(), stmt.executeQuery(...), rs.next() and rs.getInt(...) all declare to throw SQLException, which is a checked exception and hence handle or declare rule applies in this case.


As main(String []) method neither declares to throw IOException nor a catch block is available for IOException, hence code doesn't compile.

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