WorksheetsFile Handling in C++
Total questions: 20
Worksheet time: 20mins
Files store data permanently in a/ an
storage device.
array.
function.
variable.
A collection of characters that is written or read during file handling in C++ is called
variable.
stream.
bits.
numbers.
Fstream library provides C++ programmers with ___________ classes for working with files
Two
Three
Four
Five
A class which is used for reading information from data files is called
ofstream
ifstream
fstream
iostream
A class which is capable of creating files, writing to files, reading from data files is called
ofstream
ifstream
fstream
iostream
A class which is capable of creating files and writing information to files is called
ofstream
ifstream
fstream
iostream
To perform file processing in C++, header files <iostream> and <fstream> must be included in your C++ source file.
True
False
The output sent to the file is appended to it.
ios :: ate
ios :: in
ios :: out
ios :: app
ios :: trunc
It opens the file for the output then moves the read and write control to the file’s end.
ios :: ate
ios :: in
ios :: out
ios :: app
ios :: trunc
It opens the file for a read.
ios :: ate
ios :: in
ios :: out
ios :: app
ios :: trunc
It opens the file for a write.
ios :: ate
ios :: in
ios :: out
ios :: app
ios :: trunc
If a file exists, then it deletes the file content prior to its opening.
ios :: ate
ios :: in
ios :: out
ios :: app
ios :: trunc
Which of the following codes will close a file named as Sample?
close(Sample);
close.Sample();
Sample.close();
Sample(close);
Which of the following codes will open a file named as Sample for reading and writing purposes?
open("Sample.dat", ios::out | ios::in );
open(ios::out | ios::in, "Sample.dat" );
open("Sample.dat", ios::out && ios::in );
open(ios::out && ios::in, "Sample.dat" );
What is the code to open a file named as new_file in write mode and truncate it if it already exists?
open("new_file.dat", <ios.out> | <ios.trunc> );
open(<ios.out> | <ios.trunc>, "new_file.dat" );
open(ios::out | ios::trunc, "new_file.dat" );
open("new_file.dat", ios::out | ios::trunc );
What is the code to open a file named as My_Data for reading data from it?
Open("My_Data.dat", "ios::in")
Open(My_Data.dat, "ios::in")
Open("My_Data.dat", ios::in)
Open(My_Data.dat, ios::in)
What is the code to open a file named as Old_Data for writing data to it?
Open("My_Data.dat", ios::out)
Open("My_Data.dat", ios $$ out)
Open("My_Data.dat", ios..out)
Open("My_Data.dat", <iosout>)
What is the code to open a file named as Sample and remove all the previous content stored in the file?
Open(ios::trunc, "Sample.dat")
Open("Sample.dat", "ios::trunc")
Open("ios::trunc", "Sample.dat")
Open("Sample.dat", ios::trunc)
What is the code to open a file named as Updated_Data for output and move the read/write control to the end of the file?
Open("Updated_Data.dat" | ios::ate)
Open("Updated_Data.dat", ios::ate)
Open("Updated_Data.dat" && ios::ate)
Open("Updated_Data.dat" $$ ios::ate)
