Questions
Which of the following files in C++ is a file that contains information in the same format in which the information is held in the memory?
- Binary file
- Text file
- ASCII file
- Data file
- filebuf
Which of the following classes in C++ supports output operations and contains open() function with default output mode?
- fstreambase
- ifstream
- ofstream
- fstream
- filebuf
Which of the following streams in C++ receives data from a program and writes the data to a monitor that it receives from the program?
- Input stream
- Output stream
- Error stream
- File
- Data stream
Which of the following codes is used for relative position in get pointer and is used to place the file pointer, and read the contents from the beginning of a file?
- ios::cur
- ios::beg
- ios::end
- ios::out
- ios::in
Which of the following file modes is used in file handling, if an already existing file is to be opened for output operations and its previous contents are to be deleted by a new one?
- ios::app
- ios::ate
- ios::binary
- ios::trunc
- ios::out
Which of the following operators in C++ is called as an insertion operator that inserts data into an appropriate stream?
- >>
- <<
- :?
- &
- *
Which of the following program codes is correct for opening a file in append mode that sets the write pointer to end of a file?
- fstream f1;
f1.open(TEXT.DAT, ios::app); - ifstream f1;
f1.open(TEXT.DAT, ios::app); - ofstream f1;
f1.open(TEXT.DAT, ios::trunc); - fstream f1;
f1.open(TEXT.DAT, ios::out); - fstream f1;
f1.open(TEXT.DAT, ios::in);
Which of the following steps is the first step to use files in C++?
- Declaring file streams
- Including the header files
- Opening a file
- Process the file
- Closing a file
Which of the following stream classes is used in C++ to perform input and output operations on to a data file?
- istream
- ostream
- ifstream
- ofstream
- fstream
Which of the following functions in data file handling moves the file put pointer to a location specified by its arguments?
- seekg()
- tellg()
- tellp()
- seekp()
- return()
Which of the following stream classes acts as base class in the hierarchy of file stream classes?
- istream
- ostream
- iostream
- ios
- fstream
Which of the following functions is used to write the contents of the binary file associated with ofstream object?
- read()
- write()
- tellg()
- tellp()
- seekg()
Which of the following devices is connected to the input stream in C++ from which data is extracted and provided to the program for manipulation?
- Monitor
- Printer
- Keyboard
- Plotter
- Joystick
Consider the following C++ code:
textfile.open(sample.dat, ios::in);
Where is the get pointer placed after the execution of the above code?
- At the beginning of the file
- At the end of the file
- In the middle of data file
- At the current position of data file
- Automatically positioned