File Handling - C++ (MCQ) questions and answers

1)    By default, all the files are opened in ___________mode .
- Published on 19 Oct 15

a. Binary
b. Text
c. Can’t say
Answer  Explanation 

ANSWER: Text

Explanation:
No explanation is available for this question!


2)   It is not possible to combine two or more file opening mode in open () method.
- Published on 19 Oct 15

a. True
b. False
Answer  Explanation 

ANSWER: False

Explanation:
No explanation is available for this question!


3)   Which of the following is not a file opening mode ____ .
- Published on 19 Jul 15

a. ios::ate
b. ios::nocreate
c. ios::noreplace
d. ios::truncate
Answer  Explanation 

ANSWER: ios::truncate

Explanation:
No explanation is available for this question!


4)   Due to ios::trunc mode, the file is truncated to zero length.
- Published on 17 Jul 15

a. True
b. False
Answer  Explanation 

ANSWER: True

Explanation:
No explanation is available for this question!


5)   If we have object from ofstream class, then default mode of opening the file is _____ .
- Published on 17 Jul 15

a. ios::in
b. ios::out
c. ios::in|ios::trunc
d. ios::out|ios::trunk
Answer  Explanation 

ANSWER: ios::out|ios::trunk

Explanation:
No explanation is available for this question!


6)   __________ is return type of is_open() function.
- Published on 17 Jul 15

a. int
b. bool
c. float
d. char *
Answer  Explanation 

ANSWER: bool

Explanation:
No explanation is available for this question!


7)   If we have object from fstream class, then what is the default mode of opening the file?
- Published on 17 Jul 15

a. ios::in|ios::out
b. ios::in|ios::out|ios::trunc
c. ios::in|ios::trunc
d. Default mode depends on compiler
Answer  Explanation 

ANSWER: Default mode depends on compiler

Explanation:
No explanation is available for this question!


8)   To create an output stream, we must declare the stream to be of class ___________ .
- Published on 17 Jul 15

a. ofstream
b. ifstream
c. iostream
d. None of these
Answer  Explanation 

ANSWER: ofstream

Explanation:
No explanation is available for this question!


9)   Streams that will be performing both input and output operations must be declared as class _________ .
- Published on 17 Jul 15

a. iostream
b. fstream
c. stdstream
d. Stdiostream
Answer  Explanation 

ANSWER: fstream

Explanation:
No explanation is available for this question!


10)   To perform File I/O operations, we must use _____________ header file.
- Published on 17 Jul 15

a. < ifstream>
b. < ofstream>
c. < fstream>
d. Any of these
Answer  Explanation 

ANSWER: < fstream>

Explanation:
No explanation is available for this question!


1 2