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

 
 

SCJP Module-10 Question-7
Posted on: July 16, 2010 at 12:00 AM
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:

import java.io.*;

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

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

(A) Yes
(B) No

Answer:

(A)

Related Tags for SCJP Module-10 Question-7:


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.