Deck 12: Pointers, Classes, Virtual Functions, and Abstract Classes

Full screen (f)
exit full mode
Question
What is the output of the following statements? <strong>What is the output of the following statements?  </strong> A) nullptr B) 0 C) 3 D) 33 <div style=padding-top: 35px>

A) nullptr
B) 0
C) 3
D) 33
Use Space or
up arrow
down arrow
to flip the card.
Question
In C++, ____ is called the address of operator.

A) &
B) *
C) #
D) ->
Question
The dereferencing operator is also known as the indirection operator and refers to the object to which its operand points.
Question
In C++, pointer variables are declared using the reserved word pointer.
Question
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
What is the output of the following code? <strong>What is the output of the following code?  </strong> A) 12, 12 B) 12, 81 C) 81, 12 D) 81, 81 <div style=padding-top: 35px>

A) 12, 12
B) 12, 81
C) 81, 12
D) 81, 81
Question
The seqSearch function returns true if an item in the list equals the searchItem.
Question
What is the value of x after the following statements execute? <strong>What is the value of x after the following statements execute?  </strong> A) nullptr B) 0 C) 25 D) 46 <div style=padding-top: 35px>

A) nullptr
B) 0
C) 25
D) 46
Question
In C++, the member access operator arrow is >>.
Question
In C++, you declare a pointer variable by using the ____ symbol.

A) *
B) &
C) #
D) @
Question
A list is a collection of elements of the same type.
Question
What is the output of the following code? <strong>What is the output of the following code?  </strong> A) 76, 76 B) 76, 43 C) 43, 76 D) 43, 43 <div style=padding-top: 35px>

A) 76, 76
B) 76, 43
C) 43, 76
D) 43, 43
Question
The C++ operator ____ is used to destroy dynamic variables.

A) destroy
B) delete
C) *
D) ˜
Question
In the statement
int* p, q;
p and q are pointer variables.
Question
A memory leak is an unused memory space that cannot be allocated.
Question
Which of the following can be used to initialize a pointer variable?

A) 1
B) nullptr
C) "0"
D) '0'
Question
A pointer variable is a variable whose content is a memory address.
Question
The C++ operator ____ is used to create dynamic variables.

A) dynamic
B) new
C) virtual
D) dereferencing
Question
The code int *p; declares p to be a(n) ____ variable.

A) new
B) num
C) pointer
D) address
Question
In C++, the dot operator has a lower precedence than the dereferencing operator.
Question
The ____ constructor is executed when an object is declared and initialized by using the value of another object.

A) default
B) copy
C) struct
D) class
Question
The statement int *p; is equivalent to int * p;, which is also equivalent to the statement ____________________.
Question
Which of the following arithmetic operations is allowed on pointer variables?

A) Increment
B) Modulus
C) Multiplication
D) Division
Question
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 ____.

A) member-wise assignment
B) default assignment
C) member-wise initialization
D) default initialization
Question
In a ____ copy, two or more pointers of the same type point to the same memory.

A) static
B) shallow
C) dynamic
D) deep
Question
Which of the following operations is allowed on pointer variables?

A) exp
B) %
C) ==
D) /
Question
In ____ binding, the necessary code to call a specific function is generated by the compiler.

A) static
B) dynamic
C) shallow
D) deep
Question
Run-time binding is also known as ____ binding.

A) static
B) shallow
C) dynamic
D) deep
Question
Consider the following statements:In the function pointerParameters, the parameter p is a(n) ____________________ parameter.
Consider the following statements:In the function pointerParameters, the parameter p is a(n) ____________________ parameter.  <div style=padding-top: 35px>
Question
A class ____ automatically executes whenever a class object goes out of scope.

A) constructor
B) destructor
C) pointer
D) exception
Question
In a ____ copy, two or more pointers have their own data.

A) shallow
B) deep
C) static
D) dynamic
Question
Consider the following declaration of a struct:The statement (*studentPtr).gpa = 2.5; is equivalent to ___________________ = 2.5;.
Consider the following declaration of a struct:The statement (*studentPtr).gpa = 2.5; is equivalent to ___________________ = 2.5;.  <div style=padding-top: 35px>
Question
Given the declaration int *a;, the statement a = new int[50]; dynamically allocates an array of 50 components of the type ____.

A) int
B) int*
C) pointer
D) address
Question
The statement that declares board to be an array of six pointers wherein each pointer is of type int is: int ____________________;
Question
Which of the following would be appropriate syntax for the heading of a copy constructor for a class called rulerType?

A) rulerType(int inches, int centimeters)
B) rulerType()
C) rulerType(const rulerType& myRuler)
D) copy rulerType(int inches, int centimeters)
Question
The ____ operator can be used to return the address of a private data member of a class.

A) dereferencing
B) destructor
C) address of
D) member access
Question
Consider the following statements:In the function pointerParameters, the parameter q is a(n) ____________________ parameter.
Consider the following statements:In the function pointerParameters, the parameter q is a(n) ____________________ parameter.  <div style=padding-top: 35px>
Question
An array created during the execution of a program is called a(n) ____ array.

A) list
B) static
C) execution
D) dynamic
Question
In C++, virtual functions are declared using the reserved word ____.

A) virtual
B) private
C) public
D) struct
Question
Given the statement double *p;, the statement p++; will increment the value of p by ____ byte(s).

A) one
B) two
C) four
D) eight
Question
Consider the following statements:The code above is an example of a(n) ____________________ class definition.
Consider the following statements:The code above is an example of a(n) ____________________ class definition.  <div style=padding-top: 35px>
Question
A(n) ____________________ is a collection of distinct elements of the same type.
Question
The copy constructor automatically executes when, as a parameter, an object is passed by ____________________.
Question
The ____________________ of a base class automatically makes the destructor of a derived class virtual.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/44
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 12: Pointers, Classes, Virtual Functions, and Abstract Classes
1
What is the output of the following statements? <strong>What is the output of the following statements?  </strong> A) nullptr B) 0 C) 3 D) 33

A) nullptr
B) 0
C) 3
D) 33
D
2
In C++, ____ is called the address of operator.

A) &
B) *
C) #
D) ->
A
3
The dereferencing operator is also known as the indirection operator and refers to the object to which its operand points.
True
4
In C++, pointer variables are declared using the reserved word pointer.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
5
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.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
6
What is the output of the following code? <strong>What is the output of the following code?  </strong> A) 12, 12 B) 12, 81 C) 81, 12 D) 81, 81

A) 12, 12
B) 12, 81
C) 81, 12
D) 81, 81
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
7
The seqSearch function returns true if an item in the list equals the searchItem.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
8
What is the value of x after the following statements execute? <strong>What is the value of x after the following statements execute?  </strong> A) nullptr B) 0 C) 25 D) 46

A) nullptr
B) 0
C) 25
D) 46
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
9
In C++, the member access operator arrow is >>.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
10
In C++, you declare a pointer variable by using the ____ symbol.

A) *
B) &
C) #
D) @
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
11
A list is a collection of elements of the same type.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
12
What is the output of the following code? <strong>What is the output of the following code?  </strong> A) 76, 76 B) 76, 43 C) 43, 76 D) 43, 43

A) 76, 76
B) 76, 43
C) 43, 76
D) 43, 43
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
13
The C++ operator ____ is used to destroy dynamic variables.

A) destroy
B) delete
C) *
D) ˜
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
14
In the statement
int* p, q;
p and q are pointer variables.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
15
A memory leak is an unused memory space that cannot be allocated.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
16
Which of the following can be used to initialize a pointer variable?

A) 1
B) nullptr
C) "0"
D) '0'
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
17
A pointer variable is a variable whose content is a memory address.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
18
The C++ operator ____ is used to create dynamic variables.

A) dynamic
B) new
C) virtual
D) dereferencing
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
19
The code int *p; declares p to be a(n) ____ variable.

A) new
B) num
C) pointer
D) address
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
20
In C++, the dot operator has a lower precedence than the dereferencing operator.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
21
The ____ constructor is executed when an object is declared and initialized by using the value of another object.

A) default
B) copy
C) struct
D) class
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
22
The statement int *p; is equivalent to int * p;, which is also equivalent to the statement ____________________.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
23
Which of the following arithmetic operations is allowed on pointer variables?

A) Increment
B) Modulus
C) Multiplication
D) Division
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
24
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 ____.

A) member-wise assignment
B) default assignment
C) member-wise initialization
D) default initialization
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
25
In a ____ copy, two or more pointers of the same type point to the same memory.

A) static
B) shallow
C) dynamic
D) deep
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
26
Which of the following operations is allowed on pointer variables?

A) exp
B) %
C) ==
D) /
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
27
In ____ binding, the necessary code to call a specific function is generated by the compiler.

A) static
B) dynamic
C) shallow
D) deep
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
28
Run-time binding is also known as ____ binding.

A) static
B) shallow
C) dynamic
D) deep
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
29
Consider the following statements:In the function pointerParameters, the parameter p is a(n) ____________________ parameter.
Consider the following statements:In the function pointerParameters, the parameter p is a(n) ____________________ parameter.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
30
A class ____ automatically executes whenever a class object goes out of scope.

A) constructor
B) destructor
C) pointer
D) exception
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
31
In a ____ copy, two or more pointers have their own data.

A) shallow
B) deep
C) static
D) dynamic
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
32
Consider the following declaration of a struct:The statement (*studentPtr).gpa = 2.5; is equivalent to ___________________ = 2.5;.
Consider the following declaration of a struct:The statement (*studentPtr).gpa = 2.5; is equivalent to ___________________ = 2.5;.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
33
Given the declaration int *a;, the statement a = new int[50]; dynamically allocates an array of 50 components of the type ____.

A) int
B) int*
C) pointer
D) address
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
34
The statement that declares board to be an array of six pointers wherein each pointer is of type int is: int ____________________;
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
35
Which of the following would be appropriate syntax for the heading of a copy constructor for a class called rulerType?

A) rulerType(int inches, int centimeters)
B) rulerType()
C) rulerType(const rulerType& myRuler)
D) copy rulerType(int inches, int centimeters)
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
36
The ____ operator can be used to return the address of a private data member of a class.

A) dereferencing
B) destructor
C) address of
D) member access
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
37
Consider the following statements:In the function pointerParameters, the parameter q is a(n) ____________________ parameter.
Consider the following statements:In the function pointerParameters, the parameter q is a(n) ____________________ parameter.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
38
An array created during the execution of a program is called a(n) ____ array.

A) list
B) static
C) execution
D) dynamic
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
39
In C++, virtual functions are declared using the reserved word ____.

A) virtual
B) private
C) public
D) struct
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
40
Given the statement double *p;, the statement p++; will increment the value of p by ____ byte(s).

A) one
B) two
C) four
D) eight
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
41
Consider the following statements:The code above is an example of a(n) ____________________ class definition.
Consider the following statements:The code above is an example of a(n) ____________________ class definition.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
42
A(n) ____________________ is a collection of distinct elements of the same type.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
43
The copy constructor automatically executes when, as a parameter, an object is passed by ____________________.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
44
The ____________________ of a base class automatically makes the destructor of a derived class virtual.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 44 flashcards in this deck.