COP 42134

subject Type Homework Help
subject Pages 9
subject Words 1363
subject Authors Harvey Deitel, Paul J. Deitel

Unlock document.

This document is partially blurred.
Unlock all pages and 1 million more documents.
Get Access
page-pf1
Which statement is true?
a) The boss function normally knows how the worker function performs its designated
tasks.
b) A worker function may not call other worker functions.
c) "Hiding" of implementation details makes it difficult to understand software.
d) The boss function is normally unaware when a worker function calls another
function.
Q3: static member functions:
a. Can use the this pointer.
b. Can access only other static member functions and static data members.
c. Cannot be called until an object of their class is instantiated.
d. Can be declared const as well.
Q1: When an object of a derived class is instantiated, the __________ constructor
initializes the _________ members.
a. Base class, base class.
page-pf2
b. Derived class, base class.
c. Base class, derived class.
d. Derived class, public.
Advantages of typedef do not include
(a) making programs more portable by allowing data types to be easily changed to meet
system specifications.
(b) making type names shorter.
(c) making programs more readable.
(d) increasing the efficiency of accessing struct member variables.
A __________ occurs when dynamically allocated memory is not returned when it's no
longer needed.
(a) memory leak
(b) self-referential error
(c) allocation error
page-pf3
(d) sizeoferror
Q1: 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
The %i scanf conversion specifier is not capable of inputting which type of data?
a) hexadecimal
b) binary
c) decimal
d) octal
page-pf4
A switch statement should be used
(a) as a single-selection statement
(b) as a double-selection statement
(c) when a variable may assume many different values which must be tested
(d) to replace all if and ifelse statements
The # operator causes __________ to be converted to a __________.
(a) any preprocessor argument, user-defined type.
(b) a text token, string surrounded by quotes.
(c) a string, concatenated string.
(d) any float or int, string.
page-pf5
The statement #line 250
(a) causes the compiler to ignore everything after line 250.
(b) causes the compiler to renumber the lines from 250 beginning with the next source
code line.
(c) causes the compiler to renumber the lines from 250 beginning with this statement
line.
(d) causes line number 250 to be replaced by the text following the statement.
Which of the following is a non-linear data structure?
a) linked list
b) queue
c) binary tree
d) stack
Which of the following is always a syntax error?
a) Not using srand in every program that uses rand.
b) Not using rand in every program that uses srand.
page-pf6
c) Not using const when passing an array.
d) Forgetting to include the array subscript when referring to individual structures in an
array of structures.
Q1: The assignment operator (=) can be used to:
a. Test for equality.
b. Copy data from one object to another.
c. Compare two objects.
d. Copy a class.
What is the final value of x after performing the following operations?
int x = 21;
double y = 6;
double z = 14;
y = x / z;
x = 5.5 * y;
page-pf7
(a) 8.25
(b) 5.5
(c) 5
(d) 8
Q2: 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 ).
Q4: Which of the following is not allowed?
a. Objects of abstract classes.
b. Multiple pure virtual functions in a single abstract class.
c. References to abstract classes.
page-pf8
d. Arrays of pointers to abstract classes.
Which standard library header file contains function prototypes for conversions of
numbers to text and text to numbers, memory allocation, random numbers and other
utility functions.
a) <stdarg.h>
b) <stdlib.h>
c) <stdutl.h>
d) <stddef.h>
Which statement is false?
a) Function atof returns a double version of its argument.
b) If the converted value cannot be represented, the behavior of atoi is undefined.
c) When using functions from the general utilities library, its header file must be
included.
d) Function strtol receives three arguments.
page-pf9
Which of the following statements is true?
(a) The C standard library does not provide a secure random-number generator.
(b) According to the C standard document's description of function rand, "There are no
guarantees as to the quality of the random sequence produced and some
implementations are known to produce sequences with distressingly non-random
low-order bits."
(c) The CERT guideline MSC30-C indicates that implementation-specific
random-number generation functions must be used to ensure that the random numbers
produced are not predictable
(d)All of the above.
An expression such as
sizeof(arrayName) / sizeof(double)
might typically be used to determine
a) the size of an array
b) the number of elements in an array
c) the number of elements in half an array
d) the size of an element of an array
page-pfa
Which of the following statements is false?
(a) C provides automatic bounds checking for arrays.
(b) C provides no automatic bounds checking for arrays, so you must provide your own.
(c) Allowing programs to read from or write to array elements outside the bounds of
arrays are common security flaws.
(d)Writing to an out-of-bounds element (known as a buffer overflow) can corrupt a
program's data in memory, crash a program and allow attackers to exploit the system
and execute their own code.
Which definition tells the computer to reserve 12 elements for integer array c?
a) c[12] int;
b) int c [11];
c) c[11] int;
d) int c[12];
page-pfb
Which statement is true regarding the statement
++frequency[responses[answer]];
a) This statement increases the appropriate frequency counter depending on the value of
responses[answer].
b) This statement increases the appropriate answer counter depending on the value of
frequency[responses].
c) This statement increases the appropriate responses counter depending on the value of
frequency[answer].
d) This statement produces a syntax error because subscripts cannot be nested.
Which statement is false?
a) If a value should not change in the body of a function to which it is passed, the value
should be defined const to ensure that it is not accidentally modified.
b) Attempts to modify the value of a variable defined const are caught at execution
time.
c) One way to pass a pointer to a function is to use a non-constant pointer to
non-constant data.
d) It is dangerous to pass a non-pointer into a pointer argument.
page-pfc
Q1: Theoretically, clients do not need to see the _________ of classes from which they
derive other classes.
a. Header files.
b. Source code.
c. Object code.
d. Interface.
Which of the following statements is false?
a) The linear searching method works well for small arrays.
b) The linear searching method works well for unsorted arrays.
c) The binary search algorithm eliminates from consideration one half of the elements
in a sorted array after each comparison.
d) The binary search terminates only when the search key is equal to the middle
element of a subarray.
Q1: Given the class definition:
page-pfd
class CreateDestroy
{
public:
CreateDestroy() { cout << "constructor called, "; }
~CreateDestroy() { cout << "destructor called, "; }
};
What will the following program output?
int main()
{
CreateDestroy c1;
CreateDestroy c2;
return 0;
}
a. constructor called, destructor called, constructor called, destructor called,
b. constructor called, destructor called,
c. constructor called, constructor called,
d. constructor called, constructor called, destructor called, destructor called,
Which statement is true?
a) The identifiers in an enumeration must be unique.
page-pfe
b) The constant values assigned to members of an enumeration must be unique.
c) Enumeration constant names must consist of all uppercase letters.
d) Values in an enumeration start with 1 unless specified otherwise.
Q2: The array subscript operator [], when overloaded, cannot:
a. Be used with linked list classes.
b. Take a float as an operand.
c. Take multiple values inside (e.g., [4,8]).
d. Take user-defined objects as operands.
Q1: Suppose you have a programmer-defined data type Data and want to overload the
<< operator to output your data type to the screen in the form cout << dataToPrint; and
allow cascaded function calls. The first line of the function definition would be:
a. ostream &operator<<( ostream &output, const Data &dataToPrint )
b. ostream operator<<( ostream &output, const Data &dataToPrint )
c. ostream &operator<<( const Data &dataToPrint, ostream &output )
d. ostream operator<<( const Data &dataToPrint, ostream &output )
page-pff
Q8[C++11]: Which of the following is false?
a. To receive a list initializer as an argument to a constructor, you can declare the
constructor's parameter as type list_initialier<T> where T represents the type of the
values in the list initializer.
b. To receive a list initializer as an argument to a constructor, you can declare the
constructor's parameter as type initializer_list<T> where T represents the type of the
values in the list initializer.
c. It's not possible to pass a list initializer to a constructor.
d. (a) and (c).

Trusted by Thousands of
Students

Here are what students say about us.

Copyright ©2022 All rights reserved. | CoursePaper is not sponsored or endorsed by any college or university.