nerdexam
Oracle

1Z0-819 · Question #67

Given public class MyResource { public MyResource () { // Resource methods } } You want to use the MyResource class in a try-with-resources statement. Which change will accomplish this?

The correct answer is D. Implement AutoCloseable and override the close method. See the full explanation below for the reasoning.

Question

Given public class MyResource { public MyResource () { // Resource methods } } You want to use the MyResource class in a try-with-resources statement. Which change will accomplish this?

Options

  • AExtend AutoCloseable and override the close method.
  • BImplement AutoCloseable and override the autoClose method.
  • CExtend AutoCloseable and override the autoClose method.
  • DImplement AutoCloseable and override the close method.

How the community answered

(33 responses)
  • A
    3% (1)
  • B
    9% (3)
  • C
    15% (5)
  • D
    73% (24)

Community Discussion

No community discussion yet for this question.

Full 1Z0-819 Practice