What is the output of the following code?
// Cafe4JavaE2Q2
import java.io.*;
public class Cafe4JavaE2Q2 {
public static void main (String args[]) throws Exception {
File f = new File ("Cafe4Java.txt");
f.write ("Cafe4Java", 0, 4);
f.flush();
f.close();
FileReader fr = new FileReader ("Cafe4Java.txt");
BufferedReader br = new BufferedReader (fr);
String text = br.readLine();
System.out.println (text);
}
}
- A)
The code throws a runtime exception.
- B)
The code fails to compile.
- C) The code prints out the following value:
Cafe4Java
- D) The code prints out the following value:
Cafe
Answer to Q2
<<<< Back to Q1 <<<<
>>>> Go to Q3 >>>>
Submit your feedback on this mock exam