C++ mcqs for interviews and exam preparation for all levels of education. Object oriented programming basic mcqs. share on
1. ios::trunc is used for?
A. If the file is opened for output operations and it already existed, no action is taken.
B. If the file is opened for output operations and it already existed, then a new copy is created.
C. If the file is opened for output operations and it already existed, its previous content is deleted and replaced by the new one.
D. None of the above
2. 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);
3. Which operator is used to insert the data into file?
A. >>
B. <<
C. <
D. None of the above
4. 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
5. 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
6.It is not possible to combine two or more file opening mode in open () method.
A.TRUE
B. FALSE
C. May Be
D. Can’t Say
7. Which stream class is to only write on files ?
A. ofstream
B. ifstream
C. fstream
D. iostream
8. 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.
9. Which member function is used to determine whether the stream object is currently associated with a file?
A. is_open
B. Buf
C. String
D. None of the above
10. getc() returns EOF when
A. End of files is reached
B. When getc() fails to read a character
C. Both A & B
D. None of the above