This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Mock Exam Errata and the fly likes Boone # 44 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Mock Exam Errata
Bookmark "Boone # 44" Watch "Boone # 44" New topic

Boone # 44

Stewart Henry

Joined: Jun 01, 2001
Posts: 4
The Question is:

The answer is given as e, and indeed when I compile and run this code on NT that is what happens. However, I think this code is getting away cheap because it never calls out.close().
I remembered from my C/UNIX days that you always had to call flush() then close() before the program terminated otherwise you got an empty file, partial contents, or plain junk. I think that d might also be an appropriate answer depending on the JVM and what the operating system is doing at the time when you run this code.
Is java different then C in respect calling close()?
Jyotsna Umesh
Ranch Hand

Joined: May 09, 2001
Posts: 94
Hi Stewart,
Your question is interesting. Its always better to close the any open files, it cleans up the memory resources but even id you don't the randon access file will bot be blank, it will show you the right data that you have added.
But its healthy practise to close any open file when you are through with the task.
I agree. Here's the link:
subject: Boone # 44
Similar Threads
dear all, i created a set of mock exam, please try it.
File q from mock exam -- ??? -confused!
File q, help requested!
Boone's Exam - Question 44