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


Share on Google+Share on Google+
SCJP Module-10 Question-5
Posted on: July 16, 2010 at 12:00 AM
This sample code will test your understanding of opening a file and writing data onto the file.

Given a sample code:

1    import java.io.*;

2    class Test3 {
3    public static void main(String[] args) {
4    try {
5    // Place code here.
6    w.write("hello user");
7    w.close();
8    } catch (IOException e) {
9    System.out.println(e);

What code can be placed at line no 5 for creating a file and writing to it ? Choose the correct options?

(A) FileWriter w = new FileWriter("user.txt");
(B) File w = new File("user.txt");




Related Tags for SCJP Module-10 Question-5:

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