Share on Google+Share on Google+

SCJP Module-10 Question-7

The sample code given below will test your understanding of creating a file and writing data onto it by using the File and FileWriter respectively.

Given a sample code:


class Test3 {
public static void main(String[] args) {
try {
File w = new File("test.txt");
FileWriter fw = new FileWriter(w);
fw.write("test message");
} catch (IOException e) {

Is the above code can make a file and can write ? Choose correct option?

(A) Yes
(B) No




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.