978-1337102087 Chapter 12

subject Type Homework Help
subject Pages 9
subject Words 559
subject Authors D. S. Malik

Unlock document.

This document is partially blurred.
Unlock all pages and 1 million more documents.
Get Access
page-pf1
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 1
1. A pointer variable is a variable whose content is a memory address.
a.
True
b.
False
ANSWER:
True
POINTS:
1
REFERENCES:
818
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
2. In C++, pointer variables are declared using the reserved word pointer.
a.
True
b.
False
ANSWER:
False
POINTS:
1
REFERENCES:
818
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
3. In the statement
int* p, q;
p and q are pointer variables.
a.
True
b.
False
ANSWER:
False
POINTS:
1
REFERENCES:
819
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
4. The dereferencing operator is also known as the indirection operator and refers to the object to which its operand
points.
a.
True
b.
False
ANSWER:
True
POINTS:
1
REFERENCES:
821
page-pf2
Name:
Class:
Date:
page-pf3
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 3
p = new int[50];
dynamically allocates an array of 50 components of type int and p contains the base address of the array.
a.
True
b.
False
ANSWER:
True
POINTS:
1
REFERENCES:
831
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
9. A memory leak is an unused memory space that cannot be allocated.
a.
True
b.
False
ANSWER:
True
POINTS:
1
REFERENCES:
832
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
10. If p is a pointer variable, the statement p = p + 1; is valid in C++.
a.
True
b.
False
ANSWER:
True
POINTS:
1
REFERENCES:
836
QUESTION TYPE:
True / False
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
11. In C++, you declare a pointer variable by using the ____ symbol.
a.
*
b.
&
c.
#
d.
@
ANSWER:
a
POINTS:
1
REFERENCES:
818
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
page-pf4
Name:
Class:
Date:
page-pf5
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 5
int x = 33;
int *q;
q = &x;
cout << *q << endl;
a.
nullptr
b.
0
c.
3
d.
33
ANSWER:
d
POINTS:
1
REFERENCES:
821
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
16. What is the output of the following code?
int *p;
int x;
x = 76;
p = &x;
*p = 43;
cout << x << ", " << *p << endl;
a.
76, 76
b.
76, 43
c.
43, 76
d.
43, 43
ANSWER:
d
POINTS:
1
REFERENCES:
821
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
17. What is the output of the following code?
int *p;
int x;
x = 12;
p = &x;
cout << x << ", ";
*p = 81;
cout << *p << endl;
a.
12, 12
b.
12, 81
c.
81, 12
d.
81, 81
ANSWER:
b
POINTS:
1
page-pf6
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 6
REFERENCES:
821
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
18. Which of the following can be used to initialize a pointer variable?
a.
1
b.
nullptr
c.
"0"
d.
'0'
ANSWER:
b
POINTS:
1
REFERENCES:
829
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
19. The C++ operator ____ is used to create dynamic variables.
a.
dynamic
b.
new
c.
virtual
d.
dereferencing
ANSWER:
b
POINTS:
1
REFERENCES:
830
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
20. The C++ operator ____ is used to destroy dynamic variables.
a.
destroy
b.
delete
c.
*
d.
˜
ANSWER:
b
POINTS:
1
REFERENCES:
833
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
21. Which of the following operations is allowed on pointer variables?
a.
exp
b.
%
c.
==
d.
/
ANSWER:
c
page-pf7
Name:
Class:
Date:
page-pf8
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 8
c.
execution
d.
dynamic
ANSWER:
d
POINTS:
1
REFERENCES:
837
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
26. In a ____ copy, two or more pointers of the same type point to the same memory.
a.
static
b.
shallow
c.
dynamic
d.
deep
ANSWER:
b
POINTS:
1
REFERENCES:
847
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
27. In a ____ copy, two or more pointers have their own data.
a.
shallow
b.
deep
c.
static
d.
dynamic
ANSWER:
b
POINTS:
1
REFERENCES:
847
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
28. A class ____ automatically executes whenever a class object goes out of scope.
a.
constructor
b.
destructor
c.
pointer
d.
exception
ANSWER:
b
POINTS:
1
REFERENCES:
849
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
29. Consider the following statement:
page-pf9
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 9
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
ANSWER:
c
POINTS:
1
REFERENCES:
851
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
30. 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
ANSWER:
b
POINTS:
1
REFERENCES:
853
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
31. 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)
ANSWER:
c
POINTS:
1
REFERENCES:
854
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
32. In C++, virtual functions are declared using the reserved word ____.
a.
virtual
b.
private
c.
public
d.
struct
page-pfa
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 10
ANSWER:
a
POINTS:
1
REFERENCES:
861
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
33. In ____ binding, the necessary code to call a specific function is generated by the compiler.
a.
static
b.
dynamic
c.
shallow
d.
deep
ANSWER:
a
POINTS:
1
REFERENCES:
860
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
34. Run-time binding is also known as ____ binding.
a.
static
b.
shallow
c.
dynamic
d.
deep
ANSWER:
c
POINTS:
1
REFERENCES:
861
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
35. 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
ANSWER:
c
POINTS:
1
REFERENCES:
874
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
36. Consider the following declaration of a struct:
page-pfb
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 11
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;.
ANSWER:
studentPtr->gpa
POINTS:
1
REFERENCES:
827
QUESTION TYPE:
Completion
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
37. Consider the following statements:
void pointerParameters(int* &p, double *q)
{
.
.
.
}
In the function pointerParameters, the parameter p is a(n) ____________________ parameter.
ANSWER:
reference
POINTS:
1
REFERENCES:
842
QUESTION TYPE:
Completion
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
38. Consider the following statements:
void pointerParameters(int* &p, double *q)
{
.
.
.
}
In the function pointerParameters, the parameter q is a(n) ____________________ parameter.
page-pfc
Name:
Class:
Date:
Copyright Cengage Learning. Powered by Cognero.
Page 12
ANSWER:
value
POINTS:
1
REFERENCES:
842
QUESTION TYPE:
Completion
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
39. The statement that declares board to be an array of six pointers wherein each pointer is of type int is: int
____________________;
ANSWER:
*board[6]
POINTS:
1
REFERENCES:
842
QUESTION TYPE:
Completion
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
40. The copy constructor automatically executes when, as a parameter, an object is passed by ____________________.
ANSWER:
value
POINTS:
1
REFERENCES:
853
QUESTION TYPE:
Completion
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
41. The binding of virtual functions occurs at program ____________________ time.
ANSWER:
execution
run
POINTS:
1
REFERENCES:
861
QUESTION TYPE:
Completion
HAS VARIABLES:
False
DATE CREATED:
10/5/2016 1:41 PM
DATE MODIFIED:
10/5/2016 1:41 PM
42. The ____________________ of a base class automatically makes the destructor of a derived class virtual.
ANSWER:
virtual destructor
POINTS:
1
REFERENCES:
865
QUESTION TYPE:
Completion
HAS VARIABLES:
False
page-pfd
Name:
Class:
Date:

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.