(Choose 1 answer)
import java.io.*;
What happens when you try to compile and run the following application?
class A {
String name; int age;
A(String na, int ag) {name=na;age=ag;}}
public class Main{
public static void main(String argv[]){
try {
File f = new File("xxx.ser");
FileOutputStream fos = new FileOutputStream(f);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(new A("HOA",22)); //(1)
oos.close(); //(2)
}
}
fos.close();}
catch (Exception x) {}
A. Compiler error at line (1).
B. An exception is thrown at line (1).
C. An exception is thrown at line (2).
D. No compiler error and no exception.
Q: 26