cool hit counter
Cafe4Java
Cafe4Java
 

SCJP Mock Exam 2 - Q3
Q3)
What is the output of the following code?

// Cafe4JavaE2Q3
import java.io.*;

public class Cafe4JavaE2Q3 {
  public static void main (String args[]) throws Exception {
    File file = new File ("Cafe4Java.txt");
    FileWriter fw = new FileWriter (file);
    fw.write ("Cafe4Java", 0, 9);
    fw.flush();
    fw.close();
    System.out.println(new BufferedReader (new FileReader (file)).readLine());
  }
}


  • A) The code prints out:
    Cafe4Java
    
  • B) The code prints out:
    Cafe
    
  • C) The code fails to compile.
  • D) The code throws a runtime exception.
Answer to Q3


    <<<< Back to Q2 <<<<         >>>> Go to Q4 >>>>

Submit your feedback on this mock exam


 
 
Custom Search
     
Cafe4Java