File Handling - placement practice test

File Handling - placement practice test


1. To perform File I/O operations, we must use _____________ header file.

a. < ifstream>
b. < ofstream>
c. < fstream>
d. Any of these
View Answer / Hide Answer

ANSWER: c.< fstream>




2. To create an output stream, we must declare the stream to be of class_____________

a. ofstream
b. ifstream
c. iostream
d. None of these
View Answer / Hide Answer

ANSWER: a. ofstream




3. Streams that will be performing both input and output operations must be declared as class_________

a. iostream
b. fstream
c. stdstream
d. stdiostream
View Answer / Hide Answer

ANSWER: b. fstream




4. Which of the following is not a file opening mode—

a. ios::ate
b. ios::nocreate
c. ios::noreplace
d. ios::truncate
View Answer / Hide Answer

ANSWER: d. ios::truncate
Explanation:: It is just ios::trunc mode.




5. It is not possible to combine two or more file opening mode in open () method.

a.True
b. False
View Answer / Hide Answer

ANSWER: b. False
Explanation:: We can combine two or more than two file opening modes by ORing them.




6. By default, all the files are opened in ___________mode

a. Binary
b. Text
c. Can’t say
View Answer / Hide Answer

ANSWER: b. Text




7. Due to ios::trunc mode, the file is truncated to zero length.

a. True
b. False
View Answer / Hide Answer

ANSWER: a. True




8. If we have object from ofstream class, then default mode of opening the file is________

a. ios::in
b. ios::out
c. ios::in|ios::trunc
d. ios::out|ios::trunk
View Answer / Hide Answer

ANSWER: d. ios::out|ios::trunk




9. If we have object from fstream class, then default mode of opening the file is________

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

ANSWER: d. Default mode depends on compiler




10. __________is return type of is_open() function.

a. int
b. bool
c. float
d. char *
View Answer / Hide Answer

ANSWER: b. bool




11. Which of the following is not used to seek a file pointer?

a. ios::cur
c: ios::end
b. ios::set
d. ios::beg
View Answer / Hide Answer

ANSWER: b. ios::set



Post your comment