-
What will be printed to the output and written to the file, in the below program?
import java.io.*;
public class FileOutputStreamExample
{
public static void main(String args[])
{
try
{
FileOutputStream FOS = new FileOutputStream("D:\\InterviewMania.txt");
String str="Welcome to the Interview Mania.";
byte q[]=str.getBytes();//converting string into byte array
FOS.write(q);
FOS.close();
System.out.println("Success");
} catch(Exception e){System.out.println(e);}
}
}
-
- Only "Welcome to the Interview Mania"
- Compile time error
- "Success" to the output and "Welcome to the xInterview Mania"
- Runtime error
- None of these
Correct Option: C
First, it will print “Success” and besides that it will write “Welcome to the Interview Mania” to the file InterviewMania.txt.