COSC 29185

subject Type Homework Help
subject Pages 10
subject Words 1596
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
Q2: Base class constructors and assignment operators:
a. Are not inherited by derived classes.
b. Should not be called by derived class constructors and assignment operators.
c. Can be inherited by derived classes, but generally are not.
d. Can call derived-class constructors and assignment operators.
Which data type should normally not be used to control a counting loop?
a) int
b) float
c) short
d) long
The __________ sign is also known as the __________ operator.
(a) +, assignment
(b) =, assignment
(c) *, stream manipulator
page-pf2
(d) &, stream insertion
Consider the following function:
void reverse(char * string1, const char * string2)
{
int stringsize = sizeof(string1)/sizeof(char);
*(string1 + stringsize " 1) = '\0';
string1 = string1 + stringsize " 2;
for (; *string2 != '\0'; --string1, ++string2) {
*string1 = *string2;
}
}
What method does the function use to refer to array elements?
(a) array/subscript notation
(b) array/offset notation
(c) pointer/subscript notation
(d) pointer/offset notation
page-pf3
Which statement is true?
a) The members of a union can be of any type.
b) The members of a union must all be of the same type.
c) A union may not be assigned to another union of the same type.
d) Unions may be compared to other unions of the same type.
An uninitialized variable contains ________.
(a) the value last stored in the memory location reserved for that variable
(b) no value
(c) a value of zero
(d) a randomly assigned value
Which statement is true?
page-pf4
a) A symbolic constant is an identifier that is replaced with replacement text by the C
preprocessor after the program is compiled.
b) Using symbolic constants to specify array sizes makes programs run faster.
c) Preprocessor directives are not C statements.
d) The #define preprocessor directive must end in a semicolon.
Which statement is generally false?
a) Control counting loops with integer values.
b) Indent the statements in the body of each control statement for clarity.
c) Put a blank line before and after each major control statement to make it stand out in
the program.
d) The more deeply nested a program is, the easier it is to understand.
An operator that associates from right to left is
(a) !=
(b) ,
(c) ()
page-pf5
(d) ?:
Q1: 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.
Q4[C++11]: Which of the following statements is true?
a. In C++11, all classes can be used as base classes.
b. In C++11, only classes that are not declared as final can be used as base classes.
c. In C++11, only classes that are declared as base can be used as base classes.
d. None of the above
page-pf6
Q3: Call-by-reference can achieve the security of call-by-value when:
a. The value being passed is small.
b. A large argument is passed in order to improve performance.
c. A pointer to the argument is used.
d. The const qualifier is used.
Q1: 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.
page-pf7
Which of the following is not a valid escape sequence?
(a) \n
(b) \\
(c) \~
(d) "
The link member in the last node of a stack is typically set to __________ indicate the
bottom of the stack.
a) void
b) void *
c) NULL
d) empty
Which statement is false?
a) Each file used in a program must have a unique name and will have a different file
pointer returned by fopen.
b) All subsequent file processing functions after the file is opened must refer to the file
page-pf8
with the appropriate file control block.
c) To create a file use file open mode "w".
d) To add records to an existing file, pen the file for appending ("a").
Function fscanf is equivalent to function scanf, except that fscanf
a) can have only a single argument.
b) can read only from standard streams.
c) can read only from open streams.
d) receives as an argument a file pointer for the file from which the data is read.
The #include directive
a) must begin in column 1
b) includes a file in the program at execution time
c) includes a file in the program before compilation
d) appends a file to the end of the program
page-pf9
A macro commonly defined in the stdio.h header file is
a) #define getchar() getchar(stdin)
b) #define getchar() getc(stdin)
c) #define getc() getchar (stdin)
d) #define getc() getc(stdin)
What happens if the loop-continuation test is omitted in a for-statement?
a) C assumes the condition is false, so the loop terminates.
b) A syntax error occurs.
c) C assumes the condition is true, so the loop executes one more time, then terminates.
d) An infinite loop.
page-pfa
typedef is used to
(a) create a name that is an alias for a previously defined data type.
(b) create new data types.
(c) cast one struct to another type.
(d) initialize struct members.
The statement
while (--counter >= 1) {
printf("%s\n", counter % 2 ? "even" : "odd");
}
can not be rewritten as
(a)
while (--counter >= 1) {
if (counter % 2) {
puts("even");
}
else {
puts("odd");
}
}
(b)
while (counter >= 1) {
if (counter % 2) {
puts("even");
}
else {
puts("odd");
}
}
--counter;
(c)
while (counter >= 1) {
if (counter % 2) {
puts("even");
}
else {
puts("odd");
}
--counter;
}
(d)
do {
printf("%s\n", counter % 2 ? "odd" : "even");
--counter;
} while (counter >= 2);
page-pfc
__________ is not an advantage of linked lists when compared to arrays.
(a) Dynamic memory allocation
(b) Efficient insertion and deletion
(c) Direct access to any list element
(d) Efficient use of memory
Q1: Select the false statement. Depending on the compiler:
a. A failed new operation can return a 0.
b. A failed new operation can throw a bad_alloc exception.
c. A failed new operation can throw an exception if the <new> header file has been
included.
d. A failed new operation can automatically be caught at compile time.
page-pfd
Which of the following would output a "%" sign when used in the format control string
of the printf statement?
(a) %/
(b) /%
(c) %%
(d) none of these
Which of the following most closely reflects the principle of least privilege.
a) Always grant a function at least enough access to the data in its parameters to
accomplish its specified task.
b) Always grant a function enough access to the data in its parameters to accomplish its
specified task, but no more.
c) Always grant a function the least amount of access to the data in its parameters.
d) Never grant a function access to the data in its parameters.
An array containing 3 columns and 4 rows is typically referred to as a __________.
a) 12-element array
page-pfe
b) 3-by-4 array
c) 13-element array, because of the zero element
d) 4-by-3 array
When a number gets assigned to a variable that already has a value __________.
(a) the new number overwrites the previous value at that memory location
(b) the new number gets assigned to a neighboring memory location
(c) the computer issues an error
(d) the new value is destroyed and the old value remains
Lines beginning with a # are processed
a) at execution time.
b) at compile time.
c) at preprocessor time.
d) at postprocessor time.
page-pff
Pointers are variables that contain __________ as their values.
a) strings
b) flowlines
c) memory addresses
d) directions
__________ provide communication channels between files and programs.
a) Streams
b) Records
c) File descriptors
d) File control blocks (FCBs)
page-pf10
Which statement is true?
a) To test multiple conditions in the process of making a decision requires logical
operators.
b) The keywords for the logical operators are AND, OR and NOT.
c) The logical AND of two expressions is true if and only if each of the conditions is
true.
d) Truth tables deal only with cases in which all conditions are truthful (i.e., true).

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.