Ask 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. 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.

+5
Answers (1)
  1. 16 January, 01:47
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers