//this is the mock from : http://www.geocities.com/SiliconValley/Orchard/9362/java/javacert/newboone40-70.html
//I think the answer is c: a file can only be opened for either reading or writing, not both, but the answer is a.
//and I also think only the RandomAccessFile can be done both same time,
//am I right?? thanks!
Question 38: What does the following code do?
File f = new File("hello.test");
FileOutputStream out = new FileOutputStream(f);
Select the one right answer.
Create a new file named "hello.test" if it does not yet exist. It also opens the file so
you can write to it and read from it.
a.Create a new file named "hello.test" if it does not yet exist. The file is not opened.
b.Open a file named "hello.test" so that you can write to it and read from it, but
does not create the file if it does not yet exist.
c.Open a file named "hello.test" so that you can write to it but cannot read from it.
d.Create an object that you can now use to create and open the file named
"hello.test," and write to and read from the file.
//I think the answer is c: a file can only be opened for either reading or writing, not both, but the answer is a.
//and I also think only the RandomAccessFile can be done both same time,
//am I right?? thanks!
Question 38: What does the following code do?
File f = new File("hello.test");
FileOutputStream out = new FileOutputStream(f);
Select the one right answer.
Create a new file named "hello.test" if it does not yet exist. It also opens the file so
you can write to it and read from it.
a.Create a new file named "hello.test" if it does not yet exist. The file is not opened.
b.Open a file named "hello.test" so that you can write to it and read from it, but
does not create the file if it does not yet exist.
c.Open a file named "hello.test" so that you can write to it but cannot read from it.
d.Create an object that you can now use to create and open the file named
"hello.test," and write to and read from the file.