Chapter 12 Flashcards

1
Q

True or false:
A pointer variable whose content is a memory address.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

True or false:
In C++, pointer variables are declared using the reserved word pointer.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

True or false:
In the statement:
int* p, q;
p and q are pointer variables.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

True or false:
The dereferencing operator is also known as the indirection operator and refers to the object to which its operand points.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

True or false:
In C++, the dot operator has a lower precedence than the dereferencing operator.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

True or false:
In C++, the member access operator arrow is&raquo_space;.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

True or false:
Variables that are created during program execution are called static variables.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

True or false:
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.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

True or false:
A memory leak is an unused memory space that cannot be allocated.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

True or false:
If p is a pointer variable, the statement p = p + 1; is valid in C++.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

In C++, you declare a pointer by using the _______ symbol.

A

*

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

The code int *p; declared p to be a(n) _____ variable.

A

pointer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

In C++, ________ is called the address of operator.

A

&

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the value of x after the following statements execute?
int x = 25;
int *p;
p = &x;
*p = 46;

A

46

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the output of the following statements?
int x = 33;
int *q;
q = &x;
cout &laquo_space;*q &laquo_space;endl;

A

33

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the output of the following code?
int *p;
int x;
x = 76;
p = &x;
*p = 43;
cout &laquo_space;x &laquo_space;”, “ &laquo_space;*p &laquo_space;endl;

A

43, 43

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is the output of the following code?
int *p;
int x;
x = 12;
p = &x;
cout &laquo_space;x &laquo_space;”, “;
*p = 81;
cout &laquo_space;*p &laquo_space;endl;

A

12, 81

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Which of the following can be used to initialize a pointer variable?

A

nullptr

19
Q

The C++ operator ____ is used to create dynamic variables.

A

new

20
Q

The C++ operator _________ is used to destroy dynamic variables.

A

delete

21
Q

Which of the following operations is allowed on pointer variables?

A

==

22
Q

Which of the following arithmetic operations is allowed on pointer variables?

A

increment

23
Q

Given the statement double *p;, the statement p++; will increment the value of p by _____ byte(s).

A

eight

24
Q

Given the declaration int *a;, the statement a = new int[50]; dynamically allocates an array of 50 components of the type ______.

A

int

25
Q

An array created during the execution of a program is called a(n) _______ array.

A

dynamic

26
Q

In a ________ copy, two or more pointers of the same type point to the same memory.

A

shallow

27
Q

In a ______ copy, two or more pointers have their own data.

A

deep

28
Q

A class _________ automatically executes whenever a class object goes out of scope.

A

destructor

29
Q

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 initialization

30
Q

The ______ constructor is executed when an object is declared and initialized by using the value of another object.

A

copy

31
Q

Which of the following would be appropriate syntax for the heading of a copy constructor for a class called rulerType?

A

rulerType(const rulerType& myRuler)

32
Q

In C++, virtual functions are declared using the reserved word _______.

A

virtual

33
Q

In ________ binding, the necessary code to call a specific function is generated by the compiler.

A

static

34
Q

Run-time binding is also known as ________ binding.

A

dynamic

35
Q

The _________ operator can be used to return the address of a private data member of a class.

A

address of

36
Q

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;

A

studentPtr ->gpa

37
Q

Consider the following statements:
void pointerParameters(int* &p, double *q)
{…}
In the function pointerParameters, the parameter p is a(n) __________ parameter.

A

reference

38
Q

Consider the following statements:
void pointerParameters(int* &p, double *q)
{…}
In the function pointerParameters, the parameter q is a(n) __________ parameter.

A

value

39
Q

The statement that declared board to be an array of six pointers wherein each pointer is of type int is: int ______

A

*board[6]

40
Q

The copy constructor automatically executes when, as a parameter, an object is passed by __________.

A

value

41
Q

The binding of virtual functions occurs at program __________ time.

A

execution

42
Q

The _______________ of a base class automatically makes the destructor of a derived class virtual.

A

virtual destructor

43
Q

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.

A

abstract