import java.io.*; 
public class

Loading

Choose the correct option.

import java.io.*; 
public class MyProgram {
public static void main(String args[]) {
FileOutputStream out = null;
try {
out = new FileOutputStream("test.txt");
out.write(122);
}
catch(IOException io) {
System.out.println("IO Error.");
}
finally {
out.close();
}
}
}

and given that all methods of class FileOutputStream, including close(), throw an IOException, which of these is true?

A. This program will compile successfully.
B. This program fails to compile due to an error at line 4.
C. This program fails to compile due to an error at line 6.
D. This program fails to compile due to an error at line 18.

Leave a Comment