Check sibling questions

Which of the following mode in file opening statement results or generates an error if the file does not exist?

(a) a+

(b) r+

(c) w+

(d) None of the abov

 

Answer:

Checking the options:

  • (a) a+ - creates a new file or opens an existing file for reading and writing.  
  • (b) r+ - throws an error if the file does not exist or opens an existing file without truncating it for reading and writing.
  • (c) w+ - creates a new file or truncates an existing file, then opens it for reading and writing.
  • (d) None of the above

So, the correct answer is (b).

  1. Computer Science - Class 12
  2. Solutions to CBSE Sample Paper - Computer Science Class 12

About the Author

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science and Computer Science at Teachoo