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

 
 

Share on Google+Share on Google+
SCJP Module-10 Question-6
Posted on: July 16, 2010 at 12:00 AM
Advertisement
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)

Advertisement

Related Tags for SCJP Module-10 Question-6:


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.

Posted on: July 16, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com