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.
You might also like to view...
Polling is when a terminal is asked
a. if it is ready to receive b. if it has data to send c. if it is logged on d. none of the above
A(n) Web application is designed to run from a removable storage device, such as a USB flash drive.
Answer the following statement true (T) or false (F)
The _________ section break inserts a section break without starting a new page.? A. Continuous B. Even Page C. Odd Page D. Periodic
Fill in the blank(s) with the appropriate word(s).
Each class definition can contain its own constructor function, named either ____________________ or the same name as the class.
Fill in the blank(s) with the appropriate word(s).