CSC102 Chapter 12 Quiz

24 July 2022
4.7 (114 reviews)
44 test answers

Unlock all answers in this set

Unlock answers (40)
question
pointer
answer
The code int *p; declares p to be a(n) ____ variable.
question
& or ampersand
answer
In C++, ____ is called the address of operator.
question
*board[6]
answer
The statement that declares board to be an array of six pointers wherein each pointer is of type int is: int ____________________;
question
value
answer
The copy constructor automatically executes when, as a parameter, an object is passed by ____________________.
question
destructor
answer
A class ____ automatically executes whenever a class object goes out of scope.
question
43, 43
answer
What is the output of the following code? int *p; int x; x = 76; p = &x; *p = 43; cout << x << ", " << *p << endl;
question
virtual
answer
In C++, virtual functions are declared using the reserved word ____.
question
static
answer
In ____ binding, the necessary code to call a specific function is generated by the compiler.
question
46
answer
What is the value of x after the following statements execute? int x = 25; int *p; p = &x; *p = 46;
question
deep
answer
In a ____ copy, two or more pointers have their own data.
question
nullptr
answer
Which of the following can be used to initialize a pointer variable? a. '0' b. 1 c. "0" d. nullptr
question
new
answer
The C++ operator ____ is used to create dynamic variables.
question
False, they are declared using *
answer
T/F? In C++, pointer variables are declared using the reserved word pointer.
question
delete
answer
The C++ operator ____ is used to destroy dynamic variables.
question
copy
answer
The ____ constructor is executed when an object is declared and initialized by using the value of another object.
question
rulerType(const rulerType& myRuler)
answer
Which of the following would be appropriate syntax for the heading of a copy constructor for a class called rulerType? a. rulerType() b. copy rulerType(int inches, int centimeters) c. rulerType(const rulerType& myRuler) d. rulerType(int inches, int centimeters)
question
==
answer
Which of the following operations is allowed on pointer variables? a. % b. / c. == d. exp
question
True
answer
T/F? A memory leak is an unused memory space that cannot be allocated.
question
reference
answer
void pointerParameters(int* &p, double *q) { . . . } In the function pointerParameters, the parameter p is a(n) ____________________ parameter.
question
virtual destructor
answer
The ____________________ of a base class automatically makes the destructor of a derived class virtual.
question
dynamic
answer
An array created during the execution of a program is called a(n) ____ array.
question
False, only p is the ptr var.
answer
(T/F?) In the statement int* p, q; p and q are pointer variables.
question
False.
answer
(T/F?) In C++, the dot operator has a lower precedence than the dereferencing operator.
question
member-wise initialization
answer
Consider the following statement: ptrMemberVarType objectThree(objectOne); The values of the member variables of objectOne are being copied into the corresponding member variables of objectThree. This initialization is called the ____.
question
Increment
answer
Which of the following arithmetic operations is allowed on pointer variables? a. Multiplication b. Division c. Increment d. Modulus
question
8
answer
Given the statement double *p;, the statement p++; will increment the value of p by ____ byte(s).
question
True
answer
T/F? The dereferencing operator is also known as the indirection operator and refers to the object to which its operand points.
question
execution or run
answer
The binding of virtual functions occurs at program ____________________ time.
question
*
answer
In C++, you declare a pointer variable by using the ____ symbol.
question
12, 81
answer
What is the output of the following code? int *p; int x; x = 12; p = &x; cout << x << ", "; *p = 81; cout << *p << endl;
question
abstract
answer
Consider the following statements: class shape { public: virtual void draw() = 0; virtual void move(double x, double y) = 0; . . . }; The code above is an example of a(n) ____________________ class definition.
question
int* p;
answer
The statement int *p; is equivalent to int * p;, which is also equivalent to the statement ____________________.
question
studentPtr->gpa
answer
Consider the following declaration of a struct: struct studentType { char name[26]; double gpa; int sID; char grade; }; studentType student; studentType *studentPtr; The statement (*studentPtr).gpa = 2.5; is equivalent to ___________________ = 2.5;
question
dynamic
answer
Run-time binding is also known as ____ binding.
question
True.
answer
(T/F?) A pointer variable is a variable whose content is a memory address.
question
shallow
answer
In a ____ copy, two or more pointers of the same type point to the same memory.
question
int
answer
Given the declaration int *a;, the statement a = new int[50]; dynamically allocates an array of 50 components of the type ____.
question
33
answer
What is the output of the following statements? int x = 33; int *q; q = &x; cout << *q << endl;
question
False
answer
T/F? Variables that are created during program execution are called static variables.
question
True.
answer
T/F? If p is a pointer variable, the statement p = p + 1; is valid in C++.
question
address of
answer
The ____ operator can be used to return the address of a private data member of a class.
question
True.
answer
T/F? Given the declaration int *p; The statement p = new int[50]; dynamically allocates an array of 50 components of type int and p contains the base address of the array.
question
value
answer
Consider the following statements: void pointerParameters(int* &p, double *q) { . . . } In the function pointerParameters, the parameter q is a(n) ____________________ parameter.
question
False, it is ->
answer
(T/F?) In C++, the member access operator arrow is >>.