SCJP Module-10 Question-3


 

SCJP Module-10 Question-3

The Sample example given below will test your understanding of creating a file using File class on the local disk.

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)

Ads