Ask Question
12 October, 14:05

Which is the best programming practice?

a. Open a file as soon as your program begins and close the file just before your program ends.

b. Open a file as soon as your program begins but close the file as soon as you have finished using it.

c. Open a file when the program needs to work with it but close the file just before your program ends.

d. Open a file when the program needs to work with it and close the file as soon as you have finished using it.

+2
Answers (1)
  1. 12 October, 17:26
    0
    Open a file when the program needs to work with it and close the file as soon as you have finished using it.

    Explanation:

    In programming, we have some files that are stored in memory, or created in some other section of the program to save information.

    for example, we want to save the data of a class or school faculty to create a database. For this purpose I need to create a file.

    As the files that we will create may contains data, these files will utilize computer resources such as, memory (RAM, Cache) and other resources. While programming, we need these resources as well.

    Therefore, It is necessary to open a file when the program needs to work with it and close the file as soon as we have finished using it. The reason is that, it takes computer resources which are limited.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Which is the best programming practice? a. Open a file as soon as your program begins and close the file just before your program ends. b. ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers