Deck 13: Stream Inputoutput: a Deeper Look

ملء الشاشة (f)
exit full mode
سؤال
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.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
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) setbase(16) and hex have different effects on stream output.
D) setbase takes an argument but hex does not.
سؤال
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.
سؤال
Which C++ data type was designed to store Unicode characters?

A) char
B) long
C) wchar_t
D) size_t
سؤال
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(string);
D) cout << *string;
سؤال
Which of the following classes is deepest in the inheritance hierarchy?

A) basic_iostream
B) basic_ofstream
C) basic_ifstream
D) basic_fstream
سؤال
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
سؤال
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.
سؤال
What will be output by the following statements? double x{1.23456789};
Cout << fixed;
Cout << setprecision(5) << x << endl;
Cout.precision(3);
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
سؤال
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.
سؤال
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.
سؤال
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);
سؤال
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.
سؤال
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.
سؤال
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.
سؤال
__________ 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.
سؤال
2.1 Q2 [C++11] Which of the following statements is false?

A) The C++ standard redesigned the classic C++ stream classes, which processed only chars, as class templates with specializations for processing characters of types char and wchar_t, respectively.
B) C++11 added type char64_t to handle the new double-width Unicode characters.
C) The size of type wchar_t is not specified by the C++ standard.
D) C++11's new char16_t and char32_t types for representing Unicode characters were added to provide character types with explicitly specified sizes.
سؤال
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.
سؤال
Which of the following is not an object of the ostream class?

A) cout
B) cerr
C) cin
D) clog
سؤال
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.
سؤال
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)
سؤال
Which of the following is not true about bool values and how they're 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.
سؤال
Which of the following statements restores the default fill character?

A) cout.defaultFill();
B) cout.fill();
C) cout.fill(0);
D) cout.fill(' ');
سؤال
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.
سؤال
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.
سؤال
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
سؤال
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.
سؤال
What will be output by the following statements? double x{.0012345};
Cout << fixed << x << endl;
Cout << scientific << x << endl;

A) 1.234500e-03 0.001234
B) 1.23450e-03 0.00123450
C) .001234 1.234500e-03
D) 0.00123450 1.23450e-03
سؤال
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).
سؤال
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.
سؤال
Overloaded operators can be used to test a stream's state in conditions. The operator! member function, inherited into the stream classes from class basic_ios, returns true if the badbit, the failbit or both are true. The ________ member function (added in C++11) returns false if the badbit is true, the failbit is true or both are true.

A) operator boolalpha
B) operator!
C) operator boolean
D) operator bool
سؤال
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.
سؤال
What will be output by the following statement? cout << showpoint << setprecision(4) << 11.0 << endl;

A) 11
B) 11.0
C) 11.00
D) 11.000
سؤال
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 Deck
1/34
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 13: Stream Inputoutput: a Deeper Look
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
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) setbase(16) and hex have different effects on stream output.
D) setbase takes an argument but hex does not.
C
3
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.
D
4
Which C++ data type was designed to store Unicode characters?

A) char
B) long
C) wchar_t
D) size_t
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
5
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(string);
D) cout << *string;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
6
Which of the following classes is deepest in the inheritance hierarchy?

A) basic_iostream
B) basic_ofstream
C) basic_ifstream
D) basic_fstream
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
7
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
8
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
9
What will be output by the following statements? double x{1.23456789};
Cout << fixed;
Cout << setprecision(5) << x << endl;
Cout.precision(3);
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
10
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
11
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
12
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);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
13
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
14
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
15
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
16
__________ 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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
17
2.1 Q2 [C++11] Which of the following statements is false?

A) The C++ standard redesigned the classic C++ stream classes, which processed only chars, as class templates with specializations for processing characters of types char and wchar_t, respectively.
B) C++11 added type char64_t to handle the new double-width Unicode characters.
C) The size of type wchar_t is not specified by the C++ standard.
D) C++11's new char16_t and char32_t types for representing Unicode characters were added to provide character types with explicitly specified sizes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
18
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
19
Which of the following is not an object of the ostream class?

A) cout
B) cerr
C) cin
D) clog
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
20
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
21
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)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
22
Which of the following is not true about bool values and how they're 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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
23
Which of the following statements restores the default fill character?

A) cout.defaultFill();
B) cout.fill();
C) cout.fill(0);
D) cout.fill(' ');
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
25
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
27
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
28
What will be output by the following statements? double x{.0012345};
Cout << fixed << x << endl;
Cout << scientific << x << endl;

A) 1.234500e-03 0.001234
B) 1.23450e-03 0.00123450
C) .001234 1.234500e-03
D) 0.00123450 1.23450e-03
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
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).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
30
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
31
Overloaded operators can be used to test a stream's state in conditions. The operator! member function, inherited into the stream classes from class basic_ios, returns true if the badbit, the failbit or both are true. The ________ member function (added in C++11) returns false if the badbit is true, the failbit is true or both are true.

A) operator boolalpha
B) operator!
C) operator boolean
D) operator bool
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
32
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
33
What will be output by the following statement? cout << showpoint << setprecision(4) << 11.0 << endl;

A) 11
B) 11.0
C) 11.00
D) 11.000
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
34
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.