Exercise

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


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


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


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


9.Which is correct syntax for, position n bytes back from end of fileObject ?

A. FileObject.seekg(ios::end, n);
B. FileObject.seekg(n, ios:end );
C. FileObject.seekg(n, ios::end );
D. FileObject.seekg(ios:end, n);

View Answer


10. When fopen() is not able to open a file, it returns

A. EOF
B. Null
C. Runtime error
D. Compiler dependent

View Answer


11.By default, all the files are opened in which of the following mode?

A. Binary Mode
B. Text Mode
C. Sequential Mode
D. Both A and B

View Answer


12.How many objects are used for input and output to a string?

A. 1
B. 2
C. 3
D. 4

View Answer


13.Calling the stream's member function sync() causes an immediate synchronization.

A. Yes
B. NO

View Answer


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

A. ios::cur
B. ios::beg
C. ios::end
D. ios::set

View Answer


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

View Answer


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

View Answer


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

View Answer


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

View Answer


19. 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() doesn't work for empty file
D. All of the above

View Answer


20.Which function is used to position back from the end of file object?

A. Seekg
B. Seekp
C. Both seekg & seekp
D. None of the above

View Answer



Discussion

* You must be logged in to add comment.