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

 
 

SCJP Module-10 Question-3
Posted on: July 16, 2010 at 12:00 AM
The Sample example given below will test your understanding of creating a file using File class on the local disk.

Suppose you have a test.txt file at C:\work\satya directory and you want to access this file from the java code given below:

1    import java.io.*;
2    public class Test {
3    public static void main(String[] args) throws Exception {
4    File file = new File("Place code here");
5    System.out.println(file.exists());
}}

So what statement should be placed at line no 4 for accessing test.txt file. Assume you are using widow platform. Choose the correct option?

(A) C:\work\satya\test.txt
(B) C:\\work\\satya\\test.txt 
(C) C://work//satya//test.txt
(D) C:/work/satya/test.txt

Answer:

(B)

Related Tags for SCJP Module-10 Question-3:


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.