Deck 14: File Processing

ملء الشاشة (f)
exit full mode
سؤال
To write fixed-length records, use file open mode:

A) ios::app
B) ios::ate
C) ios::trunc
D) ios::binary
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Which of the following is not true about files?

A) C++ views each file as a sequential stream of bytes.
B) Files are opened by creating objects of stream classes.
C) Member functions of stream objects can be applied to file streams.
D) istream, ostream and iostream are derived from ifstream, ofstream and fstream, respectively.
سؤال
Which of the following does not have a stream associated with it?

A) cerr.
B) cin.
C) cout.
D) All of the above have streams associated with them.
سؤال
Which of the following will not change the file-position pointer to the same position as the others? Assume a 10-byte file size and a current position at byte # 1.

A) fileObject.seekg(2);
B) fileObject.seekg(1, ios::cur);
C) fileObject.seekg(2, ios::beg);
D) fileObject.seekg(8, ios::end);
سؤال
Random access files are more effective than sequential files for:

A) Instant access to data.
B) Updating data easily.
C) Inserting data into the file without destroying other data.
D) All of the above.
سؤال
What is not true about this code segment? location = fileObject.tellg();

A) tellg is a member function of fileObject.
B) location is a pointer.
C) The value of location after the segment executes must be less than or equal to the number of bytes in the file attached to fileObject.
D) fileObject is an istream object.
سؤال
Which of the following functions would not be used to write data randomly to a random access file?

A) tellg
B) seekp
C) write
D) All of the above would be used.
سؤال
Which file open mode would be used to write data only at the end of an existing file?

A) ios::app
B) ios::in
C) ios::out
D) ios::trunc
سؤال
Select the false statement.

A) C++ imposes no structure on a file.
B) C++ files include information about their structure.
C) The programmer must impose a structure on a file.
D) C++ files do not understand notions such as "records" and "fields."
سؤال
The new C++14 stream manipulator ________ enables a program to read quoted text from a stream, including any white space characters in the quoted text, and discards the double quote delimiters. For example, if we read 100 "Janie Jones" 24.98
Using
InClientFile>> account>> quoted(name)>> balance;
The first stream extraction reads 100 into the int variable account, the second reads Janie Jones as one string and stores it in the string variable name without the double-quote delimiters, and the third stream extraction reads 24.98 into the double variable balance.

A) discard
B) quoted
C) hide
D) literal
سؤال
Select the false statement. The write function:

A) Creates unformatted data.
B) Expects data type const char* as its first argument.
C) Writes to files in hexadecimal format.
D) Takes an argument of type size_t.
سؤال
Select the proper object type. __________ file("file.dat", ios::in | ios::out);

A) iostream
B) fstream
C) ofstream
D) ifstream
سؤال
A random access file is organized most like a(n):

A) Array.
B) Object.
C) Class.
D) Pointer.
سؤال
In order to perform file processing in C++, which header files must be included?

A) , and .
B) and .
C) and .
D) and .
سؤال
For an ifstream object A, a class type B and a local variable of type B called C, the proper way to read in one B object from A into C is:

A) A.read(&C, sizeof(B));
B) A.read(reinterpret_cast(&C), sizeof(B));
C) A.read(reinterpret_cast(&C), B);
D) A.read(char* (&C), sizeof(B));
سؤال
Select the false statement. The reinterpret_cast operator:

A) Changes the value of the object to which its operand points.
B) Performs its operation at compile time.
C) Is compiler-dependent and can cause programs to behave differently on different platforms.
D) Is easy to use to perform dangerous manipulations that could lead to serious execution-time errors.
سؤال
When used with ofstream objects, operator! is not:

A) Overloaded.
B) Used to determine if the open operation succeeded.
C) Used to close a file explicitly.
D) Used to return a nonzero value if an error occurs.
سؤال
Which of the following statements is true?

A) When opening a file, you can specify the name of the file only as a pointer-based string.
B) When opening a file, you can specify the name of the file only as a string object.
C) When opening a file, you can specify the name of the file as either a pointer-based string or a string object.
D) None of the above.
سؤال
Which of the following is not a disadvantage of trying to modify a sequential access file?

A) Modifying data can potentially destroy other data.
B) It may be necessary to rewrite every record in the file to make a slight change.
C) Things that are stored in the same number of "raw data" bytes internally may not take up the same amount of space in a file.
D) Overwriting a record with another record of the same size is very difficult.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/19
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 14: File Processing
1
To write fixed-length records, use file open mode:

A) ios::app
B) ios::ate
C) ios::trunc
D) ios::binary
D
2
Which of the following is not true about files?

A) C++ views each file as a sequential stream of bytes.
B) Files are opened by creating objects of stream classes.
C) Member functions of stream objects can be applied to file streams.
D) istream, ostream and iostream are derived from ifstream, ofstream and fstream, respectively.
D
3
Which of the following does not have a stream associated with it?

A) cerr.
B) cin.
C) cout.
D) All of the above have streams associated with them.
C
4
Which of the following will not change the file-position pointer to the same position as the others? Assume a 10-byte file size and a current position at byte # 1.

A) fileObject.seekg(2);
B) fileObject.seekg(1, ios::cur);
C) fileObject.seekg(2, ios::beg);
D) fileObject.seekg(8, ios::end);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
5
Random access files are more effective than sequential files for:

A) Instant access to data.
B) Updating data easily.
C) Inserting data into the file without destroying other data.
D) All of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
6
What is not true about this code segment? location = fileObject.tellg();

A) tellg is a member function of fileObject.
B) location is a pointer.
C) The value of location after the segment executes must be less than or equal to the number of bytes in the file attached to fileObject.
D) fileObject is an istream object.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
7
Which of the following functions would not be used to write data randomly to a random access file?

A) tellg
B) seekp
C) write
D) All of the above would be used.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
8
Which file open mode would be used to write data only at the end of an existing file?

A) ios::app
B) ios::in
C) ios::out
D) ios::trunc
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
9
Select the false statement.

A) C++ imposes no structure on a file.
B) C++ files include information about their structure.
C) The programmer must impose a structure on a file.
D) C++ files do not understand notions such as "records" and "fields."
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
10
The new C++14 stream manipulator ________ enables a program to read quoted text from a stream, including any white space characters in the quoted text, and discards the double quote delimiters. For example, if we read 100 "Janie Jones" 24.98
Using
InClientFile>> account>> quoted(name)>> balance;
The first stream extraction reads 100 into the int variable account, the second reads Janie Jones as one string and stores it in the string variable name without the double-quote delimiters, and the third stream extraction reads 24.98 into the double variable balance.

A) discard
B) quoted
C) hide
D) literal
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
11
Select the false statement. The write function:

A) Creates unformatted data.
B) Expects data type const char* as its first argument.
C) Writes to files in hexadecimal format.
D) Takes an argument of type size_t.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
12
Select the proper object type. __________ file("file.dat", ios::in | ios::out);

A) iostream
B) fstream
C) ofstream
D) ifstream
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
13
A random access file is organized most like a(n):

A) Array.
B) Object.
C) Class.
D) Pointer.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
14
In order to perform file processing in C++, which header files must be included?

A) , and .
B) and .
C) and .
D) and .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
15
For an ifstream object A, a class type B and a local variable of type B called C, the proper way to read in one B object from A into C is:

A) A.read(&C, sizeof(B));
B) A.read(reinterpret_cast(&C), sizeof(B));
C) A.read(reinterpret_cast(&C), B);
D) A.read(char* (&C), sizeof(B));
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
16
Select the false statement. The reinterpret_cast operator:

A) Changes the value of the object to which its operand points.
B) Performs its operation at compile time.
C) Is compiler-dependent and can cause programs to behave differently on different platforms.
D) Is easy to use to perform dangerous manipulations that could lead to serious execution-time errors.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
17
When used with ofstream objects, operator! is not:

A) Overloaded.
B) Used to determine if the open operation succeeded.
C) Used to close a file explicitly.
D) Used to return a nonzero value if an error occurs.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
18
Which of the following statements is true?

A) When opening a file, you can specify the name of the file only as a pointer-based string.
B) When opening a file, you can specify the name of the file only as a string object.
C) When opening a file, you can specify the name of the file as either a pointer-based string or a string object.
D) None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
19
Which of the following is not a disadvantage of trying to modify a sequential access file?

A) Modifying data can potentially destroy other data.
B) It may be necessary to rewrite every record in the file to make a slight change.
C) Things that are stored in the same number of "raw data" bytes internally may not take up the same amount of space in a file.
D) Overwriting a record with another record of the same size is very difficult.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.