Deck 15: Stream Inputoutput

Full screen (f)
exit full mode
Question
One difference between the three-argument version of the get function and the getline function is that:

A) Only get has a delimiter.
B) The getline function removes the delimiter from the stream.
C) Only get adds the delimiter to the array.
D) getline stores the characters it reads into its character array argument.
Use Space or
up arrow
down arrow
to flip the card.
Question
What will be output by the following statements?
Double x = 1.23456789;
Cout << fixed;
Cout << setprecision5) << x << endl;
Cout.precision3);
Cout << x << endl;
Cout << x << endl;

A) 1.2346 1.23
1)23
B) 1.23457 1.235
1)23456789
C) 1.2346 1.23
1)23456789
D) 1.23457 1.235
1)235
Question
Which of the following classes is deepest in the inheritance hierarchy?

A) basic_iostream
B) basic_ofstream
C) basic_ifstream
D) basic_fstream
Question
Which C++ data type was designed to store Unicode characters?

A) char
B) long
C) wchar_t
D) size_t
Question
If unexpected data is processed in an I/O operation:

A) An exception will be thrown.
B) An error message will automatically be displayed.
C) The program will terminate execution.
D) Various error bits will be set.
Question
The stream-extraction operator:

A) Does not normally accept white-space characters.
B) Returns true when the end-of-file is encountered.
C) Sets the stream's failbit if the operation fails.
D) Sets the stream's badbit if the data is of the wrong type.
Question
Which of the following statements is not true about C++ input/output I/O) features?

A) C++ allows users to specify I/O for their own data types.
B) C++ automatically calls the correct I/O operations for standard types.
C) C++ has some object-oriented I/O features.
D) C++ borrowed its type safe I/O capabilities from C.
Question
Which of the following is not a member function of the C++ ostream class?

A) Stream-insertion operator <<).
B) Stream-extraction operator >>).
C) put.
D) write.
Question
__________ is usually faster than __________.

A) High-level I/O, low-level I/O.
B) Low-level I/O, high-level I/O.
C) Low-level I/O, internal data processing.
D) High-level I/O, internal data processing.
Question
Select the correct statement regarding C++ I/O streams:

A) C++ provides only high-level I/O capabilities because it is a high-level programming language.
B) High-level formatted) I/O is best for large-volume transfers.
C) Low-level I/O breaks information down into small, meaningful groups of related bytes.
D) Programmers generally prefer high-level I/O to low-level I/O.
Question
Which of the following classes is a base class of the other three?

A) basic_ios
B) basic_istream
C) basic_ostream
D) basic_iostream
Question
Which of the following is not a difference between hex and setbase?

A) setbase is a parameterized stream manipulator and hex is not.
B) setbase is provided by a different header file than hex.
C) setbase16) and hex have different effects on stream output.
D) setbase takes an argument but hex does not.
Question
Which of the following is an illegal use of function put?

A) cout.put 'A' );
B) cout.put "A" );
C) cout.put 'A' ).put '\n' );
D) cout.put 65 );
Question
Which of the following is a difference between the read and write functions?

A) One performs formatted I/O and the other does not.
B) They take different types of parameters.
C) write and gcount are member functions of the same class, whereas read is not.
D) The failbit is set only with read.
Question
Which of the following prints the address of character string string given the following declaration?
Char * string = "test";

A) cout << string;
B) cout << *&string;
C) cout << static_cast< void * > string );
D) cout << * string;
Question
Upon encountering the designated delimiter character, the ignore member function will:

A) Read it in and return its value.
B) Ignore it and continue reading and discarding characters.
C) Terminate.
D) Replace it with an EOF character.
Question
Which of the following libraries does not deal with input/output?

A) iostream
B) iomanip
C) fstream
D) fiostream
Question
Which of the following is not true about setw and width?

A) If the width set is not sufficient the output prints as wide as it needs.
B) They are used to set the field width of output.
C) Both of them can perform two tasks, setting the field width and returning the current field width.
D) They only apply for the next insertion/extraction.
Question
Which of the following is not a member of the ostream class?

A) cout
B) cerr
C) cin
D) clog
Question
The putback member function returns to the input stream the previous character obtained by:

A) A get from the input stream.
B) Using the stream extraction operator on the input stream.
C) Reading input from the keyboard.
D) Reading a file from disk.
Question
Which of the following is not true about bool values and how they are output with the output stream?

A) The old style of representing true/false values used -1 to indicate false and 1 to indicate true.
B) A bool value outputs as 0 or 1 by default.
C) Stream manipulator boolalpha sets the output stream to display bool values as the strings "true" and "false".
D) Both boolalpha and noboolalpha are "sticky" settings.
Question
Which of the following is a valid user-defined output stream manipulator header?

A) ostream& tab ostream& output )
B) ostream tab ostream output )
C) istream& tab istream output )
D) void tab ostream& output )
Question
The difference between the operator! member function and the operator void* member function is that:

A) They always return opposite boolean values.
B) They occasionally return opposite boolean values.
C) Of the two member functions, only operator! checks if eof has been set.
D) Of the two member functions, only operator void* checks if eof has been set.
Question
To reset the format state of the output stream:

A) Call the reset member function.
B) Call the flags member function with the ios_base::fmtflags constant as the argument.
C) Save a copy of the fmtflags value returned by calling member function flags before making any format changes, and then call flags again with that fmtflags value as the argument.
D) You must manually apply each individual format change member function or stream manipulator to restore the default format state.
Question
Select the false statement. Outputs are:

A) Flushed automatically at the end of a program.
B) Flushed when the buffer fills.
C) Able to be synchronized with inputs.
D) Never automatically tied to inputs.
Question
Which of the following stream manipulators causes an outputted number's sign to be left justified, its magnitude to be right justified and the center space to be filled with fill characters?

A) left
B) right
C) internal
D) showpos
Question
Which of the following outputs does not guarantee that the uppercase flag has been set?

A) All hexadecimal numbers appear in the form 0X87.
B) All numbers written in scientific notation appear the form 6.45E+010.
C) All text outputs appear in the form SAMPLE OUTPUT.
D) All hexadecimal numbers appear in the form AF6.
Question
The good member function will return false if:

A) The eof member function would return true.
B) The bad member function would return true.
C) The failbit member function would return true.
D) Any of the above.
Question
Untying an input stream, inputStream, from an output stream, outputStream, is done with the function call:

A) inputStream.untie).
B) inputStream.untie &outputStream ).
C) inputStream.tie).
D) inputStream.tie 0 ).
Question
What will be output by the following statement?
Cout << showpoint << setprecision4) << 11.0 << endl;

A) 11
B) 11.0
C) 11.00
D) 11.000
Question
Which of the following statements restores the default fill character?

A) cout.defaultFill);
B) cout.fill);
C) cout.fill 0 );
D) cout.fill ' ' );
Question
When the showbase flag is set:

A) The base of a number precedes it in brackets.
B) Decimal numbers are not output any differently.
C) "oct" or "hex" will be displayed in the output stream.
D) Octal numbers can appear in one of two ways.
Question
What will be output by the following statements?
Double x = .0012345;
Cout << fixed << x << endl;
Cout << scientific << x << endl;

A) 1.234500e-003 0.001235
B) 1.23450e-003 0.00123450
C) .001235 1.234500e-003
D) 0.00123450 1.23450e-003
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/33
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 15: Stream Inputoutput
1
One difference between the three-argument version of the get function and the getline function is that:

A) Only get has a delimiter.
B) The getline function removes the delimiter from the stream.
C) Only get adds the delimiter to the array.
D) getline stores the characters it reads into its character array argument.
B
2
What will be output by the following statements?
Double x = 1.23456789;
Cout << fixed;
Cout << setprecision5) << x << endl;
Cout.precision3);
Cout << x << endl;
Cout << x << endl;

A) 1.2346 1.23
1)23
B) 1.23457 1.235
1)23456789
C) 1.2346 1.23
1)23456789
D) 1.23457 1.235
1)235
D
3
Which of the following classes is deepest in the inheritance hierarchy?

A) basic_iostream
B) basic_ofstream
C) basic_ifstream
D) basic_fstream
D
4
Which C++ data type was designed to store Unicode characters?

A) char
B) long
C) wchar_t
D) size_t
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
5
If unexpected data is processed in an I/O operation:

A) An exception will be thrown.
B) An error message will automatically be displayed.
C) The program will terminate execution.
D) Various error bits will be set.
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
6
The stream-extraction operator:

A) Does not normally accept white-space characters.
B) Returns true when the end-of-file is encountered.
C) Sets the stream's failbit if the operation fails.
D) Sets the stream's badbit if the data is of the wrong type.
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
7
Which of the following statements is not true about C++ input/output I/O) features?

A) C++ allows users to specify I/O for their own data types.
B) C++ automatically calls the correct I/O operations for standard types.
C) C++ has some object-oriented I/O features.
D) C++ borrowed its type safe I/O capabilities from C.
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
8
Which of the following is not a member function of the C++ ostream class?

A) Stream-insertion operator <<).
B) Stream-extraction operator >>).
C) put.
D) write.
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
9
__________ is usually faster than __________.

A) High-level I/O, low-level I/O.
B) Low-level I/O, high-level I/O.
C) Low-level I/O, internal data processing.
D) High-level I/O, internal data processing.
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
10
Select the correct statement regarding C++ I/O streams:

A) C++ provides only high-level I/O capabilities because it is a high-level programming language.
B) High-level formatted) I/O is best for large-volume transfers.
C) Low-level I/O breaks information down into small, meaningful groups of related bytes.
D) Programmers generally prefer high-level I/O to low-level I/O.
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
11
Which of the following classes is a base class of the other three?

A) basic_ios
B) basic_istream
C) basic_ostream
D) basic_iostream
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
12
Which of the following is not a difference between hex and setbase?

A) setbase is a parameterized stream manipulator and hex is not.
B) setbase is provided by a different header file than hex.
C) setbase16) and hex have different effects on stream output.
D) setbase takes an argument but hex does not.
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
13
Which of the following is an illegal use of function put?

A) cout.put 'A' );
B) cout.put "A" );
C) cout.put 'A' ).put '\n' );
D) cout.put 65 );
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
14
Which of the following is a difference between the read and write functions?

A) One performs formatted I/O and the other does not.
B) They take different types of parameters.
C) write and gcount are member functions of the same class, whereas read is not.
D) The failbit is set only with read.
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
15
Which of the following prints the address of character string string given the following declaration?
Char * string = "test";

A) cout << string;
B) cout << *&string;
C) cout << static_cast< void * > string );
D) cout << * string;
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
16
Upon encountering the designated delimiter character, the ignore member function will:

A) Read it in and return its value.
B) Ignore it and continue reading and discarding characters.
C) Terminate.
D) Replace it with an EOF character.
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
17
Which of the following libraries does not deal with input/output?

A) iostream
B) iomanip
C) fstream
D) fiostream
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
18
Which of the following is not true about setw and width?

A) If the width set is not sufficient the output prints as wide as it needs.
B) They are used to set the field width of output.
C) Both of them can perform two tasks, setting the field width and returning the current field width.
D) They only apply for the next insertion/extraction.
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
19
Which of the following is not a member of the ostream class?

A) cout
B) cerr
C) cin
D) clog
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
20
The putback member function returns to the input stream the previous character obtained by:

A) A get from the input stream.
B) Using the stream extraction operator on the input stream.
C) Reading input from the keyboard.
D) Reading a file from disk.
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
21
Which of the following is not true about bool values and how they are output with the output stream?

A) The old style of representing true/false values used -1 to indicate false and 1 to indicate true.
B) A bool value outputs as 0 or 1 by default.
C) Stream manipulator boolalpha sets the output stream to display bool values as the strings "true" and "false".
D) Both boolalpha and noboolalpha are "sticky" settings.
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
22
Which of the following is a valid user-defined output stream manipulator header?

A) ostream& tab ostream& output )
B) ostream tab ostream output )
C) istream& tab istream output )
D) void tab ostream& output )
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
23
The difference between the operator! member function and the operator void* member function is that:

A) They always return opposite boolean values.
B) They occasionally return opposite boolean values.
C) Of the two member functions, only operator! checks if eof has been set.
D) Of the two member functions, only operator void* checks if eof has been set.
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
24
To reset the format state of the output stream:

A) Call the reset member function.
B) Call the flags member function with the ios_base::fmtflags constant as the argument.
C) Save a copy of the fmtflags value returned by calling member function flags before making any format changes, and then call flags again with that fmtflags value as the argument.
D) You must manually apply each individual format change member function or stream manipulator to restore the default format state.
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
25
Select the false statement. Outputs are:

A) Flushed automatically at the end of a program.
B) Flushed when the buffer fills.
C) Able to be synchronized with inputs.
D) Never automatically tied to inputs.
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
26
Which of the following stream manipulators causes an outputted number's sign to be left justified, its magnitude to be right justified and the center space to be filled with fill characters?

A) left
B) right
C) internal
D) showpos
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
27
Which of the following outputs does not guarantee that the uppercase flag has been set?

A) All hexadecimal numbers appear in the form 0X87.
B) All numbers written in scientific notation appear the form 6.45E+010.
C) All text outputs appear in the form SAMPLE OUTPUT.
D) All hexadecimal numbers appear in the form AF6.
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
28
The good member function will return false if:

A) The eof member function would return true.
B) The bad member function would return true.
C) The failbit member function would return true.
D) Any of the above.
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
29
Untying an input stream, inputStream, from an output stream, outputStream, is done with the function call:

A) inputStream.untie).
B) inputStream.untie &outputStream ).
C) inputStream.tie).
D) inputStream.tie 0 ).
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
30
What will be output by the following statement?
Cout << showpoint << setprecision4) << 11.0 << endl;

A) 11
B) 11.0
C) 11.00
D) 11.000
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
31
Which of the following statements restores the default fill character?

A) cout.defaultFill);
B) cout.fill);
C) cout.fill 0 );
D) cout.fill ' ' );
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
32
When the showbase flag is set:

A) The base of a number precedes it in brackets.
B) Decimal numbers are not output any differently.
C) "oct" or "hex" will be displayed in the output stream.
D) Octal numbers can appear in one of two ways.
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
33
What will be output by the following statements?
Double x = .0012345;
Cout << fixed << x << endl;
Cout << scientific << x << endl;

A) 1.234500e-003 0.001235
B) 1.23450e-003 0.00123450
C) .001235 1.234500e-003
D) 0.00123450 1.23450e-003
Unlock Deck
Unlock for access to all 33 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 33 flashcards in this deck.