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