MPCS 64599

subject Type Homework Help
subject Pages 10
subject Words 468
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 about conditional compilation is false?
a) Conditional compilation is commonly used as a debugging aid.
b) For debugging purposes, printf statements can be enclosed in conditional
preprocessor directives so that the statements are compiled only while the debugging
process is not completed.
c) A correct example of using a conditionally compiled printf statement only while a
program is being debugged is
#ifdef DEBUG
printf("Variable x = %d\n", x) ;
#endif
d) A single, conditionally compiled printf statement may be inserted in a program
anywhere the C compiler expects a single statement.
The parentheses around the two rightmost occurrences of x in the following
preprocessor directive:
#define CIRCLE_AREA(x) ((PI) * (x) * (x))
a) are always required.
b) are included to improve program readabiliy.
c) are included to eliminate bugs when an expression is substituted for x.
d) should be curly braces { }.
page-pf2
Q1: Which of the following is false?
a. An entire non-char array cannot be input or output at once.
b. Two arrays cannot be meaningfully compared with equality or relational operators.
c. Arrays cannot be assigned to one another (i.e., array1 = array2;).
d. C++ ensures that you cannot "walk off" either end of an array.
Which statement is false?
a) C has no built-in bounds checking to prevent the computer from referring to an array
element that does not exist.
b) The programmer is responsible for implementing array bounds checking.
c) Referring to an element outside the array bounds is a syntax error.
d) Referring to an element outside the array bounds is a logic error.
Which statement is false?
page-pf3
a) Pseudocode helps you "think out" a program before attempting to write it in a
programming language such as C.
b) Pseudocode programs consist purely of characters so programmers may conveniently
type pseudocode programs into a computer using an editor program.
c) A carefully prepared pseudocode program is only a beginning; it still takes a
tremendous amount of work to convert a pseudocode program into a C program.
d) Pseudocode consists only of action statements.
The following array definition
int n[5] = {32, 27, 64, 18, 95, 14};
a) is correct
b) causes a syntax error because there are only five initializers and six array elements.
c) causes a logic error because there are only five elements but there are six initializers.
d) causes a syntax error because there are six initializers but only five array elements.
How many times will the following program print hello?
i = 1;
page-pf4
while (i <= 10) {
puts("hello");
}
(a) 10
(b) 8
(c) an infinite number of times
(d) 0
A linked program is often called a(n) __________.
a) chain
b) library
c) object
d) executable
Which statement regarding the switch statement is false?
page-pf5
a) It's appropriate for algorithms that contain a series of decisions in which a variable or
expression is tested separately for each of the constant integral values it may assume.
b) The default case is required.
c) The default case must be at the bottom of the switch after all the non-default cases.
d) Many cases may all invoke the same code.
Symbolic constants and macros can be discarded by using the __________ preprocessor
directive.
a) #undefine
b) #discard
c) #dscrd
d) #undef
Which of the following is not a correct way to initialize an array?
(a) int n[5] = {0, 7, 0, 3, 8, 2};
(b) int n[] = {0, 7, 0, 3, 8, 2};
(c) int n[5] = {7};
page-pf6
(d) int n[5] = {6, 6, 6};
Q1: An abstract class will:
a. Have all zero function pointers in its vtable.
b. Have at least one zero function pointer in its vtable.
c. Share a vtable with a derived class.
d. Have fewer zero function pointers in its vtable than concrete classes have.
Creating a new name with typedef __________.
a) creates a new type
b) creates a new type name
c) creates a new variable name
d) creates a new variable
page-pf7
Which statement is false?
a) Using bit fields can be an effective space saving technique.
b) Using bit fields always results in faster executing machine language.
c) The decision to use bit fields is one of many examples of the kinds of space-time
tradeoffs that occur in computer science.
d) An unnamed bit field with a non-zero width is used as padding in a struct of bit
fields.
Which statement is false?
a) A compound statement can be placed anywhere in a program that a single statement
can be placed.
b) The if selection statement can have only one statement in its body.
c) A set of statements contained within a pair of braces ({ and }) is called a compound
statement.
d) An if slection statement can have a compound statement in its body.
page-pf8
Q6: From most restrictive to least restrictive, the access modifiers are:
a. protected, private, public
b. private, protected, public
c. private, public, protected
d. protected, public, private
Q1: The correct order in which an exception is detected and handled is:
a. try, catch, throw
b. throw, catch, try
c. catch, throw, try
d. try, throw, catch
Q4 [C++11]: Which of the following is true?
a. The only way to define a constructor in a class is to explicitly define one.
b. If you define any constructors with arguments, the compiler will also define a default
page-pf9
constructor.
c. If you define any constructors with arguments, the compiler will not define a default
constructor.
d. You cannot explicitly create constructors.
A non-pointer variable name __________ references a value and a pointer variable
name __________ references a value.
a) directly, directly
b) directly, indirectly
c) indirectly, directly
d) indirectly, indirectly
Function __________ searches for the first occurrence in its first string argument of any
character in its second string argument.
a) strfirst
b) strstr
c) firstany
page-pfa
d) strpbrk
Q3: An overloaded + operator takes a class object and a double as operands. For it to be
commutative (i.e., a + b and b + a both work):
a. operator+ must be a member function of the class from which the objects are
instantiated.
b. operator+ must be a non-member function.
c. It must be overloaded twice; the operator+ function that takes the object as the left
operand must be a member function, and the other operator+ function must be a global
function.
d. The + operator cannot be overloaded to be commutative.
Calculating which of the following normally requires the data to be sorted first
a) mean
b) median
c) mode
page-pfb
d) total
. Keyword __________ introduces the structure definition.
a) structure
b) str
c) strdef
d) struct
Today's fastest computers are called __________.
(a) mega computers
(b) terminals
(c) supercomputers
(d) CPUs
page-pfc
Q5: Every object of the same class:
a. Gets a copy of every member function and member variable.
b. Gets a copy of every member variable.
c. Gets a copy of every member function.
d. Shares pointers to all member variables and member functions.
Q1: If dynamic memory has been allocated for an object and an exception occurs, then:
a. The catch block will not work properly.
b. A memory leak could result.
c. The object's constructor will cause another exception.
d. Multiple pointers to memory could be created.
page-pfd
Q2: static data members of a certain class:
a. Can be accessed only if an object of that class exists.
b. Cannot be changed, even by objects of the same that class.
c. Have class scope.
d. Can only be changed by static member functions.
To pass an array to a function, specify
a) the name of the array without any brackets.
b) the name of the array preceded by an empty pair of brackets.
c) the name of the array followed by a pair of brackets including the size of the array.
d) the name of the array followed by a pair of brackets including a number one less than
the size of the array.
Which of the following is false?
(a) A string may include letters, digits, and various special characters (i.e., +, -, * ).
(b) A string in C is an array of characters ending in the null character ("\0").
page-pfe
(c) String literals are written inside of single quotes
(d) A string may be assigned in a definition to either a character array or a variable of
type char *.
Which is not a formatting capability of printf?
a) representing unsigned integers in binary format
b) representing unsigned integers in decimal format
c) representing unsigned integers in hexadecimal format
d) representing unsigned integers in octal format
How many arguments can be passed to main from the command line?
(a) 1
(b) 2
(c) 3
(d) as many as you want
page-pff
Which statement is false?
a) The notations int *array and int array[] are interchangeable.
b) Function prototypes may not be placed inside functions.
c) Good advice: To encourage software reusability, when passing an array, also pass the
size of the array.
d) Global variable violate the principle of least privilege.
Which of the following statements is true in secure C programming?
(a) You should avoid using printf to display a single string argument.
(b) You should always use printf to display a single string argument.
(c) You should always use puts to display a single string argument.
(d) None of the above.
page-pf10
Q4: y and z are user-defined objects and the += operator is an overloaded member
function. The operator is overloaded such that y += z adds z and y, then stores the result
in y. Which of the following expressions is always equivalent to y += z?
a. y = y operator+= z
b. y.operator+=(z)
c. y = y + z
d. y operator+=(y + z)

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.