Given:
final class Folder { //line n1
//line n2 public void open () { System.out.print(“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? (Choose two.)
Select all that apply, then click Submit answer.
-
○
Replace line n1 with: class Folder implements AutoCloseable {
-
○
Replace line n1 with: class Folder extends Closeable {
-
○
Replace line n1 with: class Folder extends Exception {
-
○
At line n2, insert:
final void close () {
System.out.print(“Close”);
} -
○
At line n2, insert:
public void close () throws IOException {
System.out.print(“Close”);
}