nerdexam
Oracle

1Z0-809 · Question #11

Given: //line n2 public void open() { System.out.println("Open"); } } public class Test { public static void main (String [] args) throws Exception { try (Folder f = new Folder()) { f.open(); } } }…

The correct answer is A. Replace line n1 with: class Folder implements AutoCloseable { E. At line n2, insert: public void close() throws IOException { System.out.print("Close"); }. You've hit your session limit · resets 5:20pm (America/New_York)

Question

Given: //line n2 public void open() { System.out.println("Open"); } } public class Test { public static void main (String [] args) throws Exception { try (Folder f = new Folder()) { f.open(); } } } Which two modifications enable the code to print Open Close?

Options

  • AReplace line n1 with: class Folder implements AutoCloseable {
  • BReplace line n1 with: class Folder extends Closeable {
  • CReplace line n1 with: class Folder extends Exception {
  • DAt line n2, insert: final void close() { System.out.print("Close"); }
  • EAt line n2, insert: public void close() throws IOException { System.out.print("Close"); }

How the community answered

(54 responses)
  • A
    70% (38)
  • B
    9% (5)
  • C
    17% (9)
  • D
    4% (2)

Explanation

You've hit your session limit · resets 5:20pm (America/New_York)

Community Discussion

No community discussion yet for this question.

Full 1Z0-809 Practice