Question
QUESTION 18 If two pointers, each in its own object, point to the same location in the heap, and that location is freed by the
QUESTION 18
If two pointers, each in its own object, point to the same location in the heap, and that location is freed by the destruction of one of the objects, the pointer in the other object becomes a:
a)null pointer
b)constant pointer
c)destroyed pointer
d)dangling pointer
QUESTION 19
How many times is the following code invoked by the call recursive(4)?
void recursive( int i ){
if (i < 8){
cout << i << " ";
recursive(i);
}
}
a)2
b)This is infinate recursion
c)8
d)32
e)128
QUESTION 20
Which of the following is true, when we inline a function?
a)We are not indenting the body of the function, so that the body of the function is in line with the function heading.
b)It tells the compiler to substitute the function body (for the inlined function) for any function calls made (using that inlined function) throughout the program code
c)For class templates, we must write the function definition where the function prototype would normally be, in the class definition.
d)It indicates that the function should return by reference.
QUESTION 21
We would like to make a dynamic array that can store 10 Check objects, and we would declare arr to be the name of the array. We would use the line of code
a)Check *arr = new Check arr[ 10 ];
b)Check arr = new Check [10];
c)Check *arr = new Check [10];
d)Check new *arr[10];
QUESTION 22
In the remove function of the LinkedList class, when searching for the node to remove, we keep a pointer one node in front of the node we want to remove because
a)the node we are searching for might not be in the linked list.
b)we must be able to link the node (that the pointer points to) to the node following the one we want to remove.
c)if the pointer pointed to the node we wanted to remove and then we removed it, we would get a runtime error
d). if the pointer pointed to the node we wanted to remove and then we removed it, we would get a dangling reference (or dangling pointer)
e)None of the above.
QUESTION 23
A general linked list is an important data structure because
a)it can conserve more memory than an array for large element sizes
b)it is much faster than an array in almost every possible situation
c)without one, there are no data structures available for which we could search for keys
d)it is the only data structure in which each element can be a record of information
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started