0% found this document useful (0 votes)
93 views

by Default, All The Files in C++ Are Opened in - Mode

The document contains 17 multiple choice questions about file input/output operations in C++, including questions about default file opening modes, return types of open() and eof() functions, using file pointers and streams, positioning the file pointer, and opening, reading from, and closing files. Common file I/O tasks like opening, reading, positioning, and closing files are assessed. The questions cover basic concepts in working with files in C++ programs.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views

by Default, All The Files in C++ Are Opened in - Mode

The document contains 17 multiple choice questions about file input/output operations in C++, including questions about default file opening modes, return types of open() and eof() functions, using file pointers and streams, positioning the file pointer, and opening, reading from, and closing files. Common file I/O tasks like opening, reading, positioning, and closing files are assessed. The questions cover basic concepts in working with files in C++ programs.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

K.K.

Wagh Institute of Engineering Education and Research, Nashik


SE (E&TC)
Object Oriented Programming

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


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

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


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

3. Which function is used in C++ to get the current position of file pointer in a file?
a) tell_p()
b) get_pos()
c) get_p()
d) tell_pos()

4. 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.

5. The purpose of a file buffer is:


A. to use memory
B. to speed up input/output
C. to speed up arithmetic operations
D. to protect data

6. ofstream, ifstream, and fstream are:


A. libraries
B. header files
C. built in classes
D. string arrays

7. What will be the output of this program?


using namespace std;
int main ()

{
FILE *fp;
char x[1024];
fp = fopen("find.txt", "r"); // "ayushjain and prateek"
x[0] = getc(fp);
fseek(fp, 0, SEEK_END);
fseek(fp, -7L, SEEK_CUR);
fgets(x, 6, fp);
puts(x);
return 0;
}
A. ayushj
B. yushja
C. ayushja
D. prate

8. 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

9. The __________ built in class can be used to create files and read information
from them into memory.
A. instream
B. ifstream
C. ofstream
D. istream

10. fseek() should be preferred over rewind() mainly because


A. In rewind, there is no way to check if the operations completed successfully
B. rewind() doesn't work for empty files
C. rewind() does work for empty file
D. All of the above

11. 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

12. In fopen(), the open mode "wx" is sometimes preferred "w" because. i)
Use of wx is more efficient. ii) If w is used, old contents of file are erased and
a new empty file is created. When wx is used, fopen() returns NULL if file
already exists.
A. Only i
B. Only ii
C. Both i & ii
D. None of the above
13. To perform File I/O operations, we must use _____________ header file.
A. < ifstream>
B. < ofstream>
C. < fstream>
D. Any of these

14. How to get position to the nth byte of fileObject ?


A. fileObject.seekg( 'filename',n );
B. fileObject.seekg( n, 'filename' );
C. fileObject.seekg( n );
D. fileObject.seekg( n, ios::app );

15. What must be specified when we construct an object of class ostream?


A. stream
B. streambuf
C. memory
D. None of the mentioned

16. In order, the three-step process of using a file in a C++ program involves:
A. Name the file, open the file, and delete the file
B. Insert a diskette, open a file, and remove the disk
C. Open the existing file, read/write data, close the file
D. Create the file contents, close the file, and name the file

17. Which of the following is used to Open a file for output and move the
read/write control to the end of the file ?
A. ios::ate
B. ios::at
C. ios::ann
D. ios::end

18. What is the use of rewind() function in C?


A. set the position to the beginning point
B. gives current position in the file
C. set the position to desire point
D. None of these

You might also like