This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes I/O K&B Question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "I/O K&B Question" Watch "I/O K&B Question" New topic
Author

I/O K&B Question

Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
This is the self test question of K&B.

I did not under stand the question or the answer what it means.
Tried looking at the API but didn't help either.
Can some one please explalin what's going on?




And the invocation is
java Directores file2.txt

is issued from a directory that has two subdirectories "dir1" and "dir2" and that "dir1" has a file "file1.txt" and "dir2" has a file "file2.txt",
and the out put is :
false true

Which set of code fragments must be inserted?


1. String path=d;
System.out.println(file.exists() + " ");

2. String path=d;
System.out.println(file.isFile() + " ");

3. String path=File.separator + d;
System.out.println(file.exists() + " ");

4. String path=File.separator + d;
System.out.println(file.isFile() + " ");


The future belongs to those who believe in the beauty of their dreams.Dream BIG!
sharad sinha
Greenhorn

Joined: Jul 13, 2008
Posts: 26

options 1 and 2 are correct. what is the problem?
You are already inside the directory from where the command is invoked.
In the first for loop file2.txt will not be found in dir1 and will be found in dir2.
In the second for loop file2.txt is not a file inside dir1 but is a file inside dir2.


Thanks, Sharad<br />SCJP 5 (July, 2008)
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: I/O K&B Question
 
Similar Threads
Updated K&B 5 Errata - 4/16
File Question
Doubt in K&B concerning question 12
File.Separator
I/O question