Share on Google+Share on Google+

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.

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*;
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




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.


Advertisement null