File Handling
1.Which stream class is to only write on files ?
A. ofstream
B. ifstream
C. fstream
D. iostream
View Answer
2.It is not possible to combine two or more file opening mode in open () method.
A. True
B. False
View Answer
3.Which of these is the correct statement about eof() ?
A. Returns true if a file open for reading has reached the next character.
B. Returns true if a file open for reading has reached the next word.
C. Returns true if a file open for reading has reached the end.
D. Returns true if a file open for reading has reached the middle.
View Answer
4. Which of the following true about FILE *fp
A. FILE is a structure and fp is a pointer to the structure of FILE type
B. FILE is a buffered stream
C. FILE is a keyword in C for representing files and fp is a variable of FILE type
D. FILE is a stream
View Answer
Ans : A
Explanation:fp is a pointer of FILE type and FILE is a structure that store following information about opened file
5.Which of the following methods can be used to open a file in file handling?
A. Using Open ( )
B. Constructor method
C. Destructor method
D. Both A and B
View Answer
6.Which operator is used to insert the data into file?
A. >>
B. <<
C. <
D. None of the above
View Answer
Ans : B
Explanation:You can write information to a file from your program using the stream insertion operator <<.
7.Which is correct syntax ?
A. myfile:open ("example.bin", ios::out);
B. myfile.open ("example.bin", ios::out);
C. myfile::open ("example.bin", ios::out);
D. myfile.open ("example.bin", ios:out);
View Answer
Also check :
Discussion