Which of the following statements are correct?

```
I:
File file = new File("input.txt");
try (Scanner input = new Scanner(file)) {
String line = input.nextLine();
}

II:
try (File file = new File("input.txt");
Scanner input = new Scanner(file);) {
String line = input.nextLine();
}

III:
File file;
try (file = new File("input.txt");
Scanner input = new Scanner(file);) {
String line = input.nextLine();
}

IV:
File file;
Scanner input;
try (file = new File("input.txt");
input = new Scanner(file);) {
String line = input.nextLine();
}
```
a. I
b. II
c. III
d. IV

a. I
File is not a subtyp of AutoCloseable. So it cannot be used to open a resource in a try-with-resources.

Computer Science & Information Technology

You might also like to view...

To remove a field from a PivotTable, you select it and press Delete

Indicate whether the statement is true or false

Computer Science & Information Technology

Very fast memory that does not have to be refreshed is _____

Fill in the blank(s) with correct word

Computer Science & Information Technology