Share on Google+Share on Google+

SCJP Module-10 Question-6

The Sample code given below will test your understanding of writing file using FileWriter class in Java.

Given a sample code:

1    import*;

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.




Posted on: July 16, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.


Advertisement null