Deck 17: File Processing
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/11
Play
Full screen (f)
Deck 17: File Processing
1
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< char * > &C ), sizeof B ) );
C) A.read reinterpret_cast< char * > &C ), B );
D) A.read char * &C ), sizeof B ) );
A) A.read &C, sizeof B ) );
B) A.read reinterpret_cast< char * > &C ), sizeof B ) );
C) A.read reinterpret_cast< char * > &C ), B );
D) A.read char * &C ), sizeof B ) );
B
2
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.
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.
A
3
Select the false statement.
A) C++ includes object serialization by default.
B) After a serialized object has been written to a file, it can be read from the file and deserialized-that is, the type information and bytes that represent the object and its data can be used to recreate the object in memory.
C) When an object is output to disk, only the values of its attributes are output.
D) None of the above.
A) C++ includes object serialization by default.
B) After a serialized object has been written to a file, it can be read from the file and deserialized-that is, the type information and bytes that represent the object and its data can be used to recreate the object in memory.
C) When an object is output to disk, only the values of its attributes are output.
D) None of the above.
A
4
Select the proper object type.
__________ file "file.dat", ios::in | ios::out );
A) iostream
B) fstream
C) ofstream
D) ifstream
__________ file "file.dat", ios::in | ios::out );
A) iostream
B) fstream
C) ofstream
D) ifstream
Unlock Deck
Unlock for access to all 11 flashcards in this deck.
Unlock Deck
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.
A) Instant access to data.
B) Updating data easily.
C) Inserting data into the file without destroying other data.
D) All of the above.
Unlock Deck
Unlock for access to all 11 flashcards in this deck.
Unlock Deck
k this deck
6
A random access file is organized most like an):
A) Array.
B) Object.
C) Class.
D) Pointer.
A) Array.
B) Object.
C) Class.
D) Pointer.
Unlock Deck
Unlock for access to all 11 flashcards in this deck.
Unlock Deck
k this deck
7
To write fixed-length records, use file open mode:
A) ios::app
B) ios::ate
C) ios::trunc
D) ios::binary
A) ios::app
B) ios::ate
C) ios::trunc
D) ios::binary
Unlock Deck
Unlock for access to all 11 flashcards in this deck.
Unlock Deck
k this deck
8
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.
A) tellg
B) seekp
C) write
D) All of the above would be used.
Unlock Deck
Unlock for access to all 11 flashcards in this deck.
Unlock Deck
k this deck
9
Multiple file open modes are specified to the fstream constructor by separating each open mode from the next with the bitwise inclusive or operator __________.
A) ||
B) ^
C) & .d |
A) ||
B) ^
C) & .d |
Unlock Deck
Unlock for access to all 11 flashcards in this deck.
Unlock Deck
k this deck
10
In the text, we created a random access file. When we read the data back sequentially, we discovered that in the process of creating the random-access file, the data was__________.
A) merged.
B)duplicated.
C) sorted.
D) filtered.
A) merged.
B)duplicated.
C) sorted.
D) filtered.
Unlock Deck
Unlock for access to all 11 flashcards in this deck.
Unlock Deck
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.
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.
Unlock Deck
Unlock for access to all 11 flashcards in this deck.
Unlock Deck
k this deck