Loading...

C++ Multiple Choice Questions

Our C++ questions and answers focuses on all areas of C++ programming language covering 100+ topics in C++

C++ File Management MCQ | Set 1

C++ File Management | Set 1


1. Which header file is required to use file I/O operations?

a) <ifstream>
b) <ostream>
c) <fstream>
d) <iostream>



2. Which stream class is to only write on files?

a) ofstream
b) ifstream
c) iostream
d) fstream



3. Which of the following is used to create an output stream?

a) ofstream
b) ifstream
c) iostream
d) fstream



4. Which of the following is used to create a stream that performs both input and output operations?

a) ofstream
b) ifstream
c) iostream
d) fstream



5. Which of the following is not used as a file opening mode?

a) ios::trunc
b) ios::binary
c) ios::in
d) ios::ate



6. Which of the following statements are correct?
1) It is not possible to combine two or more file opening mode in open() method.
2) It is possible to combine two or more file opening mode in open() method.
3) ios::in and ios::out are input and output file opening mode respectively.

a) 1, 3
b) 2, 3
c) 3 only
d) 1, 2



7. By default, all the files in C++ are opened in _________ mode.

a) Text
b) Binary
c) ISCII
d) VTC



8. What is the use of ios::trunc mode?

a) To open a file in input mode
b) To open a file in output mode
c) To truncate an existing file to half
d) To truncate an existing file to zero



9. Which of the following is the default mode of the opening using the ofstream class?

a) ios::in
b) ios::out
c) ios::app
d) ios::trunc



10. What is the return type open() method?

a) int
b) char
c) bool
d) float



- Related Topics