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()?
posted 14 years ago
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. Jyotsna