• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Barry Mock Exam

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question 38: What does the following code do? File f = new File("hello.test");
FileOutputStream out = new FileOutputStream(f);

Select the one right answer.

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.
Correct Answer is A. But I think the correct answer is C.
Correct me if I am wrong.
 
tumbleweed
Posts: 5089
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A file is only opened once the first I/O operation take place, the first write in this case. Thats why answer A is correct.
[This message has been edited by Johannes de Jong (edited March 20, 2001).]
 
"How many licks ..." - I think all of this dog's research starts with these words. Tasty tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic