Why is it important to close files and streams ?
Javasearch.buggybread.com

Search Interview Questions


 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Interview Questions and Answers

 Q1. Why is it important to close files and streams ?Core Java
Ans. Optimizing Resource utilization. When you open a file using any programming language , that is actually a request to operating system to access the file. When such a request is made , resources are allocated by the OS. When you gracefully close those files, those resources are set free.

In Java if you don’t close the streams and files, Garbage collection identifies the open files which have lost the reference and hence will close them.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     file handling


Related Questions

  What is a stream and what are the types of Streams and classes of the Streams?
  What are the contents of Hibernate configuration file ( hibernate.cfg.xml ) ?
 Which of the following file is called deployment descriptor ?

a. application.xml
b. project.xml
c. web.xml
d. build.xml
 Within AWS S3, Why new files are available immediately for read operation but not the updates ?
  What is the purpose of dialect configured in Hibernate configuration file ?
  What are the configuration files in Hibernate ?
  Can we generate Java Documentation using Export -> JavaDoc using a jar file ?
  Name few File IO related classes and interfaces ?
 What are the ways in which an application can maintain config variables ?
  Tell something about BufferedWriter ? What are flush() and close() used for ?



Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: