Home Tutorial Java Scjp Part10 SCJP Module-10 Question-6

 
 

SCJP Module-10 Question-6
Posted on: July 16, 2010 at 12:00 AM
The Sample code given below will test your understanding of writing file using FileWriter class in Java.

Given a sample code:

1    import java.io.*;

2    class Test3 {
3    public static void main(String[] args) {
4    try {
5    File w = new File("user1.txt");
6    FileWriter fw = new FileWriter(w);
7    fw.write("helllo user");
8    fw.close();
9    } catch (IOException e) {
10  System.out.println(e);
}}

What will the result if it is compiled and run ?

(A) Makes a file
(B) Error caught at line no 6.  
(C) Compile time error.
(D) Raise run-time exception.

Answer:

(B)

Related Tags for SCJP Module-10 Question-6:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.