File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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
It's not a secret anymore!