Computer Science - Class 12
Solutions to CBSE Sample Paper - Computer Science Class 12

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

Ask a doubt
Davneet Singh's photo - Co-founder, Teachoo

Made by

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, Social Science, Physics, Chemistry, Computer Science at Teachoo.