What is the output of the following code?
// Cafe4JavaE2Q4
import java.io.*;
public class Cafe4JavaE2Q4 {
public static void main (String args[]) throws Exception {
File file = new File ("Cafe4Java.txt");
PrintWriter pw = new PrintWriter (file);
pw.write ("Cafe4Java", 0, 9);
pw.flush();
pw.close();
System.out.println(new BufferedReader (new FileReader (file)).readLine());
}
}
- A) The code compiles successfully, but fails to execute without exceptions.
- B) The code fails to compile.
- C) The code prints out:
Cafe
- D) The code prints out:
Cafe4Java
Answer to Q4
<<<< Back to Q3 <<<<
>>>> Go to Q5 >>>>
Submit your feedback on this mock exam