BTE320 Chapter 12

¡Supera tus tareas y exámenes ahora con Quizwiz!

The statement that declares board to be an array of six pointers wherein each pointer is of type int is: int ____________________;

*board[6]

In C++, ____ is called the address of operator. a. & b. * c. # d. ->

a. &

In C++, you declare a pointer variable by using the ____ symbol. a. * b. & c. # d. @

a. *

Which of the following arithmetic operations is allowed on pointer variables? a. Increment b. Modulus c. Multiplication d. Division

a. Increment

A memory leak is an unused memory space that cannot be allocated. a. True b. False

a. True

A pointer variable is a variable whose content is a memory address. a. True b. False

a. True

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 b. False

a. True

If p is a pointer variable, the statement p = p + 1; is valid in C++. a. True b. False

a. True

The dereferencing operator is also known as the indirection operator and refers to the object to which its operand points. a. True b. False

a. True

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

a. int

In ____ binding, the necessary code to call a specific function is generated by the compiler. a. static b. dynamic c. shallow d. deep

a. static

In C++, virtual functions are declared using the reserved word ____. a. virtual b. private c. public d. struct

a. virtual

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.

abstract

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

b. 12, 81

In C++, pointer variables are declared using the reserved word pointer. a. True b. False

b. False

In C++, the dot operator has a lower precedence than the dereferencing operator. a. True b. False

b. False

In C++, the member access operator arrow is >>. a. True b. False

b. False

In the statement int* p, q; p and q are pointer variables. a. True b. False

b. False

Variables that are created during program execution are called static variables. a. True b. False

b. False

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

b. copy

In a ____ copy, two or more pointers have their own data. a. shallow b. deep c. static d. dynamic

b. deep

The C++ operator ____ is used to destroy dynamic variables. a. destroy b. delete c. * d. ~

b. delete

A class ____ automatically executes whenever a class object goes out of scope. a. constructor b. destructor c. pointer d. exception

b. destructor

The C++ operator ____ is used to create dynamic variables. a. dynamic b. new c. virtual d. dereferencing

b. new

Which of the following can be used to initialize a pointer variable? a. 1 b. nullptr c. "0" d. '0'

b. nullptr

In a ____ copy, two or more pointers of the same type point to the same memory. a. static b. shallow c. dynamic d. deep

b. shallow

Which of the following operations is allowed on pointer variables? a. exp b. % c. == d. /

c. ==

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

c. address of

Run-time binding is also known as ____ binding. a. static b. shallow c. dynamic d. deep

c. dynamic

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

c. member-wise initialization

The code int *p; declares p to be a(n) ____ variable. a. new b. num c. pointer d. address

c. pointer

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)

c. rulerType(const rulerType& myRuler)

What is the output of the following statements? int x = 33; int *q; q = &x; cout << *q << endl; a. nullptr b. 0 c. 3 d. 33

d. 33

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

d. 43, 43

What is the value of x after the following statements execute? int x = 25; int *p; p = &x; *p = 46; a. nullptr b. 0 c. 25 d. 46

d. 46

An array created during the execution of a program is called a(n) ____ array. a. list b. static c. execution d. dynamic

d. dynamic

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

d. eight

The binding of virtual functions occurs at program ____________________ time.

execution

The statement int *p; is equivalent to int * p;, which is also equivalent to the statement ____________________.

int* p;

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

reference

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;.

studentPtr->gpa

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

value

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

value

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

virtual destructor


Conjuntos de estudio relacionados

Chapter 13: Peripheral and Central IV therapy

View Set

Art Hist 101: Test 4 (19th C. (Realism, Impressionism, Post Impressionism, Art Nouveau, 19th Century Architecture))

View Set

The role of banks and fractional reserves: 14.3 and 14.4

View Set

pathophysiology pain and sensory

View Set