EXAM C++ review

Your page rank:

Total word count: 13841
Pages: 50

Calculate the Price

- -
275 words
Looking for Expert Opinion?
Let us have a look at your work and suggest how to improve it!
Get a Consultant

1. The standard header file for the abs(x)function is ____.
a.< cmath > b.< ioinput >
c.< cctype >d.< cstdlib >

ANS: D < cstdlib >

2. To use the predefined function tolower, the program must include the header file ____.

a. cctype b. iostream
c. cmath d. cstdlib

ANS: A cctype

3. The output of the statement

cout &lt;&lt; tolower(‘$’) &lt;&lt; endl; is ____.

a. ‘$’ b. ‘0’ c. ‘1’
d. An error, because you cannot use tolower with ‘$’.

ANS: A ‘$’

4. Assume the following.

static_cast(‘a’) = 97 static_cast(‘A’) = 65

The output of the statement:

cout &lt;&lt; static_cast(tolower(‘B’)) &lt;&lt; endl; is ____.

a. 65 b. 67 c. 96 d. 98

4. ANS: D 98

5. The output of the statement:
cout &lt;&lt; pow(3.0, 2.0) + 5 &lt;&lt; endl; is ____.

a. 11.0 b. 12.0 c. 13.0 d. 14.0

5. ANS: D 14.0

6. The output of the statement:

cout &lt;&lt; pow(2.0, pow(3.0, 1.0)) &lt;&lt; endl; is ____.

a. 6.0 b. 7.0 c. 8.0 d. 9.0

6. ANS: C 8.0

7. Functions that do not have a return type are called ____ functions.

a. zero b. null c. void d. empty

7. ANS: C void

8. The heading of the function is also called the ____.

a. title b. function signature
c. function head d. function header

8. ANS: D function header

9. Given the following function prototype:
int test(float, char);
which of the following statements is valid?
a. cout &lt;&lt; test(12, &amp;);
b. cout &lt;&lt; test("12.0", ‘&amp;’);
c. int u = test(5.0, ‘*’);
d. cout &lt;&lt; test(’12’, ‘&amp;’);

9. ANS: C int u = test(5.0, ‘*’);

10. A variable or expression listed in a call to a function is called the ____.

a. formal parameter b. actual parameter
c. data type d. type of the function

10. ANS: B actual parameter

11. A variable listed in a function call is known as a(n) ____ parameter. A variable list in a header is known as a(n) ____ parameter.

a. actual; actual
b. formal; formal
c. actual; formal
d. formal; actual

11. ANS: C actual; formal

12. What value is returned by the following return statement?
int x = 5;
return x + 1;

a. 0 b. 5 c. 6 d. 7

12. ANS: C 6

13. Given the following function
int strange(int x, int y)
{
if (x &gt; y)
return x + y;
else return x – y;
}
what is the output of the following statement:?
cout &lt;&lt; strange(4, 5) &lt;&lt; endl;

a. -1 b. 1 c. 9 d. 20

13. ANS: A -1

14. Given the following function
int next(int x)
{
return (x + 1);
}
what is the output of the following statement?
cout &lt;&lt; next(next(5)) &lt;&lt; endl;

a. 5 b. 6 c. 7 d. 8

14. ANS: C 7

15. Which statement below about prototypes and headers is true?

a. Parameter names must be listed in the prototype, but not necessarily in the header.
b. Prototypes end with a semicolon, but headers do not.
c. Headers should come before prototypes.
d. Headers end with a semicolon, but prototypes do not.

ANS: B Prototypes end with a semicolon, but headers do not.

16. A function prototype is ____.

a. a definition, but not a declaration
b. a declaration and a definition
c. a declaration, but not a definition
d. a comment line

16. ANS: C a declaration, but not a definition

17. Given the function prototype:
float test(int, int, int);
which of the following statements is legal?

a. cout &lt;&lt; test(7, test(14, 23));
b. cout &lt;&lt; test(test(7, 14), 23);
c. cout &lt;&lt; test(14, 23);
d. cout &lt;&lt; test(7, 14, 23);

17. ANS: D cout << test(7, 14, 23);

18. Given the following function prototype:
double tryMe(double, double);,
which of the following statements is valid? Assume that all variables are properly declared.

a. cin &gt;&gt; tryMe(x);
b. cout &lt;&lt; tryMe(2.0, 3.0);
c. cout &lt;&lt; tryMe(tryMe(double, double), double);
d. cout &lt;&lt; tryMe(tryMe(float, float), float);

18. ANS: B cout << tryMe(2.0, 3.0);

19. Given the function prototype:
double testAlpha(int u, char v, double t);
which of the following statements is legal?

a. cout &lt;&lt; testAlpha(5, ‘A’, 2);
b. cout &lt;&lt; testAlpha( int 5, char ‘A’, int 2);
c. cout &lt;&lt; testAlpha(‘5.0’, ‘A’, ‘2.0’);
d. cout &lt;&lt; testAlpha(5.0, "65", 2.0);

19. ANS: A cout << testAlpha(5, ‘A’, 2);

20. Which of the following function prototypes is valid?

a. int funcTest(int x, int y, float z){}
b. funcTest(int x, int y, float){};
c. int funcTest(int, int y, float z)
d. int funcTest(int, int, float);

20. ANS: D int funcTest(int, int, float);

21. Which of the following function prototypes is valid?
a. int funcExp(int x, float v);
b. funcExp(int x, float v){};
c. funcExp(void);
d. int funcExp(x);

21. ANS: A int funcExp(int x, float v);

22. Given the following function prototype:
int myFunc(int, int);
which of the following statements is valid? Assume that all variables are properly declared.
a. cin &gt;&gt; myFunc(y);
b. cout &lt;&lt; myFunc(myFunc(7, 8), 15);
c. cin &gt;&gt; myFunc(‘2’, ‘3’);
d. cout &lt;&lt; myFunc(myFunc(7), 15);

22. ANS: B cout << myFunc(myFunc(7, 8), 15);

23. The statement:
return 8, 10;
returns the value ____.

a. 8 b. 10 c. 18 d. 80

23. ANS: B 10

24. The statement:
return 37, y, 2 * 3;
returns the value ____.

a. 2 b. 3 c. y d. 6

24. ANS: D 6

25. The statement: return 2 * 3 + 1, 1 + 5; returns the value ____.

a. 2 b. 3 c. 6 d. 7

25. ANS: C 6

26. Suppose that printHeading is a function without any parameters. Which of the following is a valid function heading?

a. void printHeading();
b. void printHeading()
c. void printHeading(noParameters);
d. void printHeading(void)

26. ANS: B void printHeading()

27. Which of the following is a legal C++ function definition?

a. void funcTest(int&amp; u, double&amp; v)
{
cout &lt;&lt; u &lt;&lt; " " &lt;&lt; v &lt;&lt; endl;
}
b. void funcTest(int&amp; u, double&amp; v);
{
cout &lt;&lt; u &lt;&lt; " " &lt;&lt; v &lt;&lt; endl;
}
c. void funcTest(int&amp; u, double&amp; v)
(
cout &lt;&lt; u &lt;&lt; " " &lt;&lt; v &lt;&lt; endl
)
d. void funcTest(int&amp; u, double&amp; v)
[
cout &lt;&lt; u &lt;&lt; " " &lt;&lt; v &lt;&lt; endl;
]

27. ANS: A void funcTest(int& u, double& v) { cout << u << " " << v << endl; }

28. There are two types of ____ parameters: value parameters and reference parameters.

a. actual b. formal
c. active d. passive

28. ANS: B formal

29. If an &amp; is attached after the data type of a formal parameter, then the formal parameter is a ____.

a. value parameter
b. reference parameter
c. global variable
d. default variable

29. ANS: B reference parameter

30. A void function accomplish has three parameters: a parameter u of type int, a parameter v of type double, and a parameter letter of type char. The parameters u and letter need to pass their values out of the function and the parameter v is to only receive the value from the calling environment. Which of the following is a correct function heading?
a. void accomplish(int&amp; u, double v, char&amp; letter)
b. void accomplish(int u, double&amp; v, char letter)
c. void accomplish(int&amp; u, double v, char&amp; letter);
d. void accomplish(int u, double&amp; v, char letter);

30. ANS: A void accomplish(int& u, double v, char& letter)

31. Consider the following definition.
void funBbeta(int&amp; one, double two)
{

}
Based on this function definition, which of the following statements is valid?
a. one is a value parameter and two is a reference parameter.
b. one is a reference parameter and two is a value parameter.
c. one and two are reference parameters.
d. one and two are value parameters.

31. ANS: B one is a reference parameter and two is a value parameter.

32. Which of the following is a legal C++ function definition?
a. void funcAlpha(int u, double v &amp;)
{
cout &lt;&lt; u &lt;&lt; " " &lt;&lt; v &lt;&lt; endl;
}
b. void funcAlpha(int #, double #)
{
cout &lt;&lt; u &lt;&lt; " " &lt;&lt; v &lt;&lt; endl;
}
c. void funcAlpha(int &amp;, double &amp;)
{
cout &lt;&lt; u &lt;&lt; " " &lt;&lt; v &lt;&lt; endl;
}
d. void funcAlpha(int u, double&amp; v)
{
cout &lt;&lt;&lt; " " &lt;&lt; v &lt;&lt; endl;
}

32. ANS: D void funcAlpha(int u, double& v) { cout <<< " " << v << endl; }

33. Suppose that you are given the following function definition:
void printSomeThing(int x)
{
for (int i = 1; i &lt;= x, i++)
cout &lt;&lt; "* ";
cout &lt;&lt; endl;
}
What is the output of the following statements?
printSomeThing(1);
printSomeThing(2);
printSomeThing(3);
a. ******
b. *
<b> </b>
* <b> </b>
c. *
<b> </b>
* <b> </b>
d. *
<b> </b>
* <b> </b>
* * <b> </b><b> </b> * *

33. ANS: B * *

34. During program execution, a(n) ____ parameter manipulates the data stored in its own memory space.
a. formal value b. actual
c. active d. passive

34. ANS: A formal value

35. When a function is called, the value of the ____ parameter is copied into the corresponding formal parameter.
a. reference b. default
c. actual d. static

35. ANS: C actual

36. ____ parameters are useful when you want to return more than one value from a function.
a. Default b. Value
c. Reference d. Automatic

36. ANS: C Reference

37. If a formal parameter is a non-constant reference parameter, its corresponding actual parameter during a function call must be a(n) ____.
a. default value b. value
c. expression d. variable

37. ANS: D variable

38. You can declare a(n) ____ parameter as a constant by using the keyword const.
a. absolute b. relative
c. reference d. actual

38. ANS: C reference

39. Suppose that you have the following function.
void mystery(int&amp; one, int two)
{
int temp

temp = one;
one = two;
two = temp;
}
What are the values of x and y after the following statements? (Assume that variables are properly declared.)
x = 10;
y = 15;
mystery(x, y);

a. x = 10; y = 10
b. x = 10; y = 15
c. x = 15; y = 10
d. x = 15; y = 15

39. ANS: D x = 15; y = 15

40. Consider the following function definition.
void strange(int&amp; u, char&amp; ch)
{
int a;

a = u++;
u = 2 * u;
a = static_cast(ch);
a++;
ch = static_cast(a);
}
What are the values of one and letter after the following statements execute?
int one =5;
char letter = ‘A’;

strange(one, letter);

a. one = 5; letter = ‘A’
b. one = 10; letter = ‘A’
c. one = 10; letter = ‘B’
d. one = 12; letter = ‘B’

40. ANS: D one = 12; letter = ‘B’

41. What is the output of the following program?
#include &lt; iostream &gt;
using namespace std;

void one(int x, int&amp; y);
void two(int&amp; s, int t);

int main()
{
int u = 1;
int v = 2;

one(u, v);
cout &lt;&lt; u &lt;&lt; " " &lt;&lt; v &lt;&lt; endl; two(u, v);
cout &lt;&lt; u &lt;&lt; " " &lt;&lt; v &lt;&lt; endl;

return 0;
}

void one(int x, int&amp; y)
{
int a;
a = x;
x = y;
y = a;
}
void two(int&amp; s, int t)
{
int b;
b = s – t;
s = t + b + 2;
t = 4 * b;
}
a. 1 1
3 1
b. 1 2
1 3
c. 1 2
2 3
d. 2 2
2 3

41. ANS: A 1 1 3 1

42. The ____ of an identifier refers to where in the program an identifier is accessible (visible).

a. area b. lifetime c. scope d. locus

42. ANS: C scope

43. ____ identifiers are not accessible outside of the function (block).

a. Local b. Global c. Internal d. External

43. ANS: A Local

44. What is the output of the following C++ code?
int alpha = 5;
int beta = 10;

alpha = alpha + 5;
{
int alpha = 20;
beta = beta + 5;
}
cout &lt;&lt; alpha &lt;&lt; " " &lt;&lt; beta &lt;&lt; endl;

a. 10 10 b. 20 15
c. 10 15 d. 15 10

44. ANS: C 10 15

45. In C++, the scope resolution operator is ____.
a. | b. . c. : d. ::

45. ANS: D ::

46. In C++ the keyword ____ can be used to access a global variable declared after the definition of a function.

a. extern b. global
c. default d. external

46. ANS: A extern

47. To declare w as an external variable of type int inside the function, the function must contain which statement?

a. external w b. external int w;
c. extern w d. extern int w;

47. ANS: D extern int w;

48. Memory for ____ variables remains allocated as long as the program executes.

a. actual b. formal c. global d. local

48. ANS: C PTS: 1

49. A variable for which memory is allocated at block entry and deallocated at block exit is called a(n) ____ variable.
a. side effect b. static
c. automatic d. global

49. ANS: C PTS: 1

50. ____ a function refers to the creation of several functions with the same name.
a. Redefining b. Overnaming
c. Overlapping d. Overloading

50. ANS: D PTS: 1

51. Suppose that you have the following declaration.
enum cars {FORD, GM, TOYOTA, HONDA};

cars domesticCars = FORD;

The statement

domesticCars = static_cast&lt;cars&gt;(domesticCars + 1);

sets the value of domesticCars to ____.

a. FORD b. GM
c. TOYOTA d. HONDA

51. ANS: B GM

52. Consider the declaration
enum sports {BASKETBALL, FOOTBALL, HOCKEY, BASEBALL, SOCCER}; which of the following statements is true?

a. SOCCER– = BASEBALL
b. BASEBALL++ = SOCCER
c. HOCKEY + FOOTBALL &lt; SOCCER
d. FOOTBALL &lt;= SOCCER

52. ANS: D FOOTBALL <= SOCCER

53. What is the output of the following code?
enum courses {ALGEBRA, BASIC, PASCAL, PHILOSOPHY, ANALYSIS};
courses registered;
registered = ALGEBRA;
cout &lt;&lt; registered &lt;&lt; endl;

a. ALGEBRA b. 0
c. 1 d. "ALGEBRA"

53. ANS: B 0

54. Which of the following statements declares the studentGrade variable?
a. enum studentGrade {A, B, C, D, F};
b. enum int {A, B, C, D, F} studentGrade;
c. enum studentGrade {A, B, C, D, F} grades;
d. enum grades {A, B, C, D, F} studentGrade;

54. ANS: D enum grades {A, B, C, D, F} studentGrade;

55. Which of the following statements creates an anonymous type?
a. enum grades {A, B, C, D, F};
b. enum grades {};
c. enum {};
d. enum {A, B, C, D, F} grades;

55. ANS: D enum {A, B, C, D, F} grades;

56. In C++, you can create aliases to a previously defined data type by using the ____ statement.

a. typedef b. using
c. namespace d. alias

56. ANS: A typedef

57. In C++, ____ is a reserved word.

a. deftype b. typedef c. typecc d. alias

57. ANS: B typedef

58. Which of the following is a valid C++ statement?

a. typedef integer; b. typedef int;
c. typedef int integer; d. typedef integer int;

58. ANS: C typedef int integer;

59. In July ____, the ANSI/ISO Standard C++ was officially approved.

a. 1996 b. 1998 c. 1999 d. 2000

59. ANS: B 1998

60. In C++, ____ is called the scope resolution operator.

a. . b. ? c. : d. ::

60. ANS: D ::

61. The scope of a namespace member is local to the ____.

a. function b. block
c. file d. namespace

61. ANS: D namespace

62. Given the following code
namespace globalType
{
void printResult();
}
which of the following statements is needed to access printResult?

a. globalType.printResult();
b. globalType.printResult;
c. globalType::printResult();
d. globalType:printResult();

62. ANS: C globalType::printResult();

63. Which of the following statements is used to simplify the accessing of all globalType namespace members?

a. using globalType;
b. using namespace globalType:all;
c. using namespace globalType::all;
d. using namespace globalType;

63. ANS: D using namespace globalType;

64. The identifiers in the system-provided header files such as iostream, cmath, and iomanip are defined in the namespace ____.

a. cctype b. stdl c. std d. stdlib

64. ANS: C std

65. Before using the data type string, the program must include the header file ____.

a. enum b. iostream c. string d. std

65. ANS: C string

66. Suppose that str1, str2, and str3 are string variables. After the following statements execute, the value of str3 is "____".
str1 = "abc";
str2 = "xyz";
str3 = str1 + ‘-‘ + str2;

a. abc b. xyz
c. abc-xyz d. xyz-abc

66. ANS: C abc-xyz

67. Suppose str = "xyzw";. After the statement str[2] = ‘Y’; The value of str is "____".

a. xyzw b. xYzw c. xyYw d. xzYw

67. ANS: C xyYw

68. The data type string has a named constant, ____, associated with it.

a. string::size b. string::size_type
c. string::pos d. string::npos

68. ANS: D string::npos

69. Suppose str = "ABCDEFGHI". The output of the statement
cout &lt;&lt; str.length() &lt;&lt; endl;
is ____.

a. 7 b. 8 c. 9 d. 10

69. ANS: C 9

70. The length of the string "Hello There. " is ____.

a. 11 b. 12 c. 13 d. 14

70. ANS: C 13

71. Consider the following statements.
string str = "ABCDEFD";
string::size_type position;
After the statement position = str.find(‘D’); executes, the value of position is ____.

a. 3 b. 4 c. 6 d. 7

71. ANS: A 3

72. Considering the statement
string str = "Gone with the wind";, the output of the statement cout &lt;&lt; str.find("the") &lt;&lt; endl; is ____.

a. 9 b. 10 c. 11 d. 12

72. ANS: B 10

73. Consider the following statements.
string str1 = "ABCDEFGHIJKLM";
string str2;
After the statement str2 = str1.substr(1,4); executes, the value of str2 is "____".

a. ABCD b. BCDE c. BCD d. CDE

73. ANS: B BCDE

74. Consider the following statements.
string str1 = "Gone with the wind";
string str2;
After the statement str2 = str1.substr(5,4); executes, the value of str2 is "____".

a. Gone b. with c. the d. wind

74. ANS: B with

75. The ____ function is used to interchange the contents of two string variables.

a. iterator b. traverse
c. swap d. change

75. ANS: C swap

76. Which of the following statements declares alpha to be an array of 25 components of the type int?

a. int alpha[25];
b. int array alpha[25];
c. int alpha[2][5];
d. int array alpha[25][25];

76. ANS: A int alpha[25];

77. Assume you have the following declaration char nameList[100];. Which of the following ranges is valid for the index of the array nameList?
a. 0 through 99
b. 0 through 100
c. 1 through 100
d. 1 through 101

77. ANS: A 0 through 99

78. Assume you have the following declaration int beta[50];. Which of the following is a valid element of beta?

a. beta[‘2’] b. beta[‘3’]
c. beta[0] d. beta[50]

78. ANS: C beta[0]

79. Assume you have the following declaration double salesData[1000];. Which of the following ranges is valid for the index of the array salesData?

a. 0 through 999
b. 0 through 1000
c. 1 through 1001
d. 1 through 1000

79. ANS: A 0 through 999

80. Suppose that list is an array of 10 components of type int. Which of the following codes correctly outputs all the elements of list?

a. for (int j = 1; j &lt; 10; j++)
cout &lt;&lt; list[j] &lt;&lt; " ";
cout &lt;&lt; endl;
b. for (int j = 0; j &lt;= 9; j++)
cout &lt;&lt; list[j] &lt;&lt; " ";
cout &lt;&lt; endl;
c. for (int j = 1; j &lt; 11; j++)
cout &lt;&lt; list[j] &lt;&lt; " ";
cout &lt;&lt; endl;
d. for (int j = 1; j &lt;= 10; j++) cout &lt;&lt; list[j] &lt;&lt; " ";
cout &lt;&lt; endl;

80. ANS: B for (int j = 0; j <= 9; j++) cout << list[j] << " "; cout << endl;

81. Suppose that sales is an array of 50 components of type double. Which of the following correctly initializes the array sales?

a. for (int 1 = 1; j &lt;= 49; j++)
sales[j] = 0;
b. for (int j = 1; j &lt;= 50; j++)
sales[j] = 0;
c. for (int j = 0; j &lt;= 49; j++)
sales[j] = 0.0;
d. for (int j = 0; j &lt;= 50; j++)
sales[j] = 0.0;

81. ANS: C for (int j = 0; j <= 49; j++) sales[j] = 0.0;

82. What is the output of the following C++ code?
int list[5] = {0, 5, 10, 15, 20};
int j;
for (j = 0; j &lt; 5; j++)
cout &lt;&lt; list[j] &lt;&lt; " ";
cout &lt;&lt; endl;

a. 0 1 2 3 4
b. 0 5 10 15
c. 0 5 10 15 20
d. 5 10 15 20

82. ANS: C 0 5 10 15 20

83. What is the value of alpha[2] after the following code executes?
int alpha[5];
int j;
for (j = 0; j &lt; 5; j++)
alpha[j] = 2 * j + 1;

a. 1 b. 4 c. 5 d. 6

83. ANS: C 5

84. What is the output of the following C++ code?
int alpha[5] = {2, 4, 6, 8, 10};
int j;
for (j = 4; j &gt;= 0; j–)
cout &lt;&lt; alpha[j] &lt;&lt; " ";
cout &lt;&lt; endl;

a. 2 4 6 8 10
b. 4 3 2 1 0
c. 8 6 4 2 0
d. 10 8 6 4 2

84. ANS: D 10 8 6 4 2

85. What is the output of the following C++ code?
int list[5] = {0, 5, 10, 15, 20};
int j;
for (j = 1; j &lt;= 5; j++)
cout &lt;&lt; list[j] &lt;&lt; " ";
cout &lt;&lt; endl;

a. 0 5 10 15 20
b. 5 10 15 20 0
c. 5 10 15 20 20
d. Code contains index out-of-bounds

85. ANS: D Code contains index out-of-bounds

86. Suppose that gamma is an array of 50 components of type int and j is an int variable. Which of the following for loops sets the index of gamma out of bounds?

a. for (j = 0; j &lt;= 49; j++)
cout &lt;&lt; gamma[j] &lt;&lt; " ";
b. for (j = 1; j &lt; 50; j++)
cout &lt;&lt; gamma[j] &lt;&lt; " ";
c. for (j = 0; j &lt;= 50; j++)
cout &lt;&lt; gamma[j] &lt;&lt; " ";
d. for (j = 0; j &lt;= 48; j++)
cout &lt;&lt; gamma[j] &lt;&lt; " ";

86. ANS: C PTS: 1

87. Consider the following declaration int alpha[5] = {3, 5, 7, 9, 11};. Which of the following is equivalent to this statement?

a. int alpha[] = {3, 5, 7, 9, 11};
b. int alpha[] = {3 5 7 9 11};
c. int alpha[5] = [3, 5, 7, 9, 11];
d. int alpha[] = (3, 5, 7, 9, 11);

87. ANS: A int alpha[] = {3, 5, 7, 9, 11};

88. Consider the following declaration int alpha[3];. Which of the following input statements correctly inputs values into alpha?
a. cin &gt;&gt; alpha
&gt;&gt; alpha
&gt;&gt; alpha;
b. cin &gt;&gt; alpha[0]
&gt;&gt; alpha[1]
&gt;&gt; alpha[2];
c. cin &gt;&gt; alpha[1]
&gt;&gt; alpha[2]
&gt;&gt; alpha[3];
d. cin &gt;&gt; alpha

88. ANS: B cin >> alpha[0] >> alpha[1] >> alpha[2];

89. In C++, the null character is represented as ____.

a. ‘\0’ b. "\0" c. ‘0’ d. "0"

89. ANS: A ‘\0’

90. Which of the following correctly declares name to be a character array and stores "William" in it?

a. char name[6] = "William";
b. char name[7] = "William";
c. char name[8] = "William";
d. char name[8] = ‘William’;

90. ANS: C char name[8] = "William";

91. Consider the following declaration char str[15];. Which of the following statements stores "Blue Sky" into str?

a. str = "Blue Sky";
b. str[15] = "Blue Sky";
c. strcpy(str, "Blue Sky");
d. strcpy("Blue Sky");

91. ANS: C strcpy(str, "Blue Sky");

92. Consider the following declaration.
char charArray[51];
char discard;
Assume that the input is:
Hello There!
How are you?

What is the value of discard after the following statements execute? cin.get(charArray, 51);
cin.get(discard);
a. discard = ‘ ‘ (Space)
b. discard = ‘!’
c. discard = ‘\n’
d. discard = ‘\0’

92. ANS: C discard = ‘\n’

93. Consider the following statement: double alpha[10][5];. The number of components of alpha is ____.

a. 15 b. 50 c. 100 d. 150

93. ANS: B 50

94. Consider the statement int list[10][8];. Which of the following about list is true?

a. list has 10 rows and 8 columns.
b. list has 8 rows and 10 columns.
c. list has a total of 18 components.
d. list has a total of 108 components.

94. ANS: A list has 10 rows and 8 columns.

95. Consider the following statement: int alpha[25][10];. Which of the following statements about alpha is true?

a. Rows of alpha are numbered 0…24 and columns are numbered 0…9.
b. Rows of alpha are numbered 0…24 and columns are numbered 1…10.
c. Rows of alpha are numbered 1…24 and columns are numbered 0…9.
d. Rows of alpha are numbered 1…25 and columns are numbered 1…10.

95. ANS: A Rows of alpha are numbered 0…24 and columns are numbered 0…9.

96. Which of the following correctly declares and initializes alpha to be an array of four rows and three columns and the component type is int?
a. int alpha[4][3] = {{0,1,2} {1,2,3} {2,3,4} {3,4,5}};
b. int alpha[4][3] = {0,1,2; 1,2,3; 2,3,4; 3,4,5};
c. int alpha[4][3] = {0,1,2: 1,2,3: 2,3,4: 3,4,5};
d. int alpha[4][3] = {{0,1,2}, {1,2,3}, {2,3,4}, {3,4,5}};

96. ANS: D int alpha[4][3] = {{0,1,2}, {1,2,3}, {2,3,4}, {3,4,5}};

97. After the following statements execute, what are the contents of matrix?
int matrix[3][2];
int j, k;

for (j = 0; j &lt; 3; j++)
for (k = 0; k &lt; 2; k++)
matrix[j][k] = j + k;

a. 0 0
1 1
2 2
b. 0 1
2 3
4 5
c. 0 1
1 2
2 3
d. 1 1
2 2
3 3

97. ANS: C 0 1 1 2 2 3

98. Given the following declaration,
int j;
int sum;
double sale[10][7];
which of the following correctly finds the sum of the elements of the fifth row of sale?

a. sum = 0; for(j = 0; j &lt; 7; j++) sum = sum + sale[5][j];
b. sum = 0; for(j = 0; j &lt; 7; j++) sum = sum + sale[4][j];
c. sum = 0; for(j = 0; j &lt; 10; j++) sum = sum + sale[5][j];
d. sum = 0; for(j = 0; j &lt; 10; j++) sum = sum + sale[4][j];

98. ANS: B sum = 0; for(j = 0; j < 7; j++) sum = sum + sale[4][j];

99. Given the following declaration,
int j;
int sum;
double sale[10][7];
which of the following correctly finds the sum of the elements of the fourth column of sale?

a. sum = 0;
for(j = 0; j &lt; 7; j++)
sum = sum + sale[j][3];
b. sum = 0;
for(j = 0; j &lt; 7; j++)
sum = sum + sale[j][4];
c. sum = 0;
for(j = 0; j &lt; 10; j++)
sum = sum + sale[j][4];
d. sum = 0;
for(j = 0; j &lt; 10; j++)
sum = sum + sale[j][3];

99. ANS: D sum = 0; for(j = 0; j < 10; j++) sum = sum + sale[j][3];

100. In row order form, the ____.

a. first row is stored first
b. first row is stored last
c. first column is stored first
d. first column is stored last

100. ANS: A first row is stored first

101. A collection of a fixed number of elements (called components) arranged in n dimensions (n&gt;=1), called a(n) ____.

a. matrix b. vector
c. n-dimensional array d. parallel array

101. ANS: C n-dimensional array

Objects

components that combine data and their operations into a single unit; instances of classes

Object-oriented design (OOD)

a programming methodology involving the use of objects that contain data members and their operations

Class

a collection of a fixed number of components with the operations you can perform on those components -defines only a data type -no memory is allocated

Members

the components of a class -if variable, declare like any other variable -if function, use function prototype to declare -if function, can directly access any member of the class -by default, members are private

defining a class (syntax)

class className { classMemberList };

private members

cannot access outside of the class -usually data members

public members

can access outside of a class -to make public, use the member access -usually methods/functions

Class object (class instance)

a class variable -built-in operations: member access (.) and assignment (=) -can be passed as parameters to functions and returned as function values -can be passed by value or by reference

accessing class members (syntax)

classObjectName.memberName

Member access operator

the dot, . (period)

passing class objects as parameters rules

-if by value: the contents of the member variables of the actual parameter are copied into the corresponding member variables of the formal parameter -if by reference: the formal parameter receives only the address of the actual parameter. when the formal parameter changes, the actual parameter also changes

Scope resolution operator

:: (double colon), used to reference identifiers

Client of a class

a program or software that uses and manipulates the objects of a class

Instance variables

non-static data members of a class. every object has its own instance of the data.

Accessor function

a member function of a class that only accesses (that is, does not modify) the value(s) of the member variable(s)

Mutator function

a member function of a class that modifies the value(s) of the member variable(s)

Default constructor

the constructor without parameters or a constructor that has default values for all parameters that is called when a class object comes into scope in a program -name is same as class -has no type, not a value-returning function nor a void function -a class can have more than 1 constructor (if more than 1, must have different formal parameter lists) -execute automatically when a class object enters its scope -if no constructor, C++ automatically provides the defualt constructor

invoking the default constructor (syntax)

className classObjectName; or className classObjectName(param1, param2, …);

constructor parameter rules

the number of parameters and their type should match the formal parameters in the order given of one of the contructors -if the type doesn’t match the formal parameters of any constructor in the order given, C++ uses type conversion and looks for the best match

Destructor

a function with no type and is not a value-returning function nor a void function. -a class can only have 1 destructor -has no parameters -automatically executes when the class object goes out of scope ~classObjectName

Implementation file

implementation details of a class contained in a separate file. contains the definitions of the functions to implement the operations of an object.

Header file (interface file)

the file that contains the specification details of a class

Precondition

a statement specifying the condition(s) that must be true before a function is called

Postcondition

a statement specifying what is true after a function call is completed

Inheritance

lets us create new classes from existing classes; an "is-a" relationship

Composition (aggregation)

where one or more members of a class are objects of another class type; a "has-a" relationship

Derived classes

the new classes that we create from base classes

Base classes

the classes from which you derive new classes

Single inheritance

an object is derived from a single class

Multiple inheritance

the derived class is derived from more than one base class

Encapsulation

the ability to combine data, and operations on that data, in a single unit

Polymorphism

the ability to use the same expression to denote different operations

Pointer variable

a variable whose content is a memory address

declaring a pointer variable (syntax)

dataType *pointerVar; ex. int *p;

Address of operator (&amp;)

a unary operator that returns the address of its operand

Dereferencing operator (indirection operator)

refers to the object to which its operand (a pointer) points

pointer rules

-a declaration of int *p; allocates memory for p only -the content of p points only to a memory location of type int -&p means the address of p -*p means the content of the memory location to which p points -can be passed as a parameter by value or by reference -the return type of a function can be a pointer

Member access operator arrow (-&gt;)

the operator -> consists of two consecutive symbols: a hyphen and the greater than symbol and is used to simplify the accessing of class components via a pointer

accessing a class member using -&gt; (syntax)

pointerVarName->classMemberName ex. (*studentPtr).gpa = 3.9; is same as studentPtr->gpa = 3.9;

Null pointer

pointer variables are initialized using the constant value ex. p = NULL; is same as p = 0;

Dynamic variables

variables that are created during program execution -use the operator new to create -use the operator delete to destroy

operator new

allocates memory (a variable) of the designated type and returns a pointer to it (the address of the allocated memory). the allocated memory is uninitialized.

new (syntax)

new dataType; (to allocate a single variable) new dataType[intExp]; (to allocate an array)

Memory leak

an unused memory space that cannot be allocated

delete (syntax)

delete pointerVariable; (to deallocate a single dynamic variable) delete [] pointerVariable; (to deallocate a dynamically created array)

operations on pointer variables

-assignment and relational operations -limited arithmetic operations (p++ increments p by 4 bytes for int, 8 bytes for double, 1 byte for char) -a pointer variable can be assigned to another pointer variable of the same type

Dynamic array

an array created during the execution of a program from a pointer variable and the new operator ex. p = new int[10]; allocates 10 contiguous memory locations of type int, stores the address of the first memory location into p

When a class object is declared, memory is allocated for ____ of each class object.

A: only the member variables
B: only the member functions
C: the member variables and the member functions
D: the member variables and function parameters

A: only the member variables

The name of a destructor function is the ____ character followed by the class name.

A: tilde
B: asterisk
C: underscore
D: ampersand

A: tilde

In C++, the dot, . (period), is an operator called the _____.

A: object access operator
B: member access operator
C: class access operator
D: member access specifier

B: member access operator

Which of the following is true of a class?

A: It grows and shrinks during program execution.
B: Its components must be of the same type.
C: It contains operations, but not data.
D: It contains both data and operations.

D: It contains both data and operations.

If a member of a class is a function, you typically use the function ____ to declare that member.

A: definition
B: prototype
C: parameters
D: type

B: prototype

Any class member that needs to be accessed outside of the class should be declared ____.

A: protected
B: public
C: private
D: static

B: public

You access a class member outside a class by using the class object name and the ____.

A: member access operator
B: member access specifier
C: scope resolution operator
D: assignment operator

A: member access operator

A member function of a class is called a _____ function if its heading contains the reserved word const at the end.

A: constant
B: accessor
C: mutator
D: instance

A: constant

If a class object is passed by _____, the contents of the member variables of the actual parameter are copied into the corresponding member variables of the formal parameter.

A: value
B: reference
C: either value or reference
D: None of the above.

A: value

A(n) ____ function modifies the value(s) of the class member variable(s).

A: header
B: accessor
C: constant
D: mutator

D: mutator

A class object is ____ if it is created once when the control reaches its declaration and destroyed when the program terminates.

A: automatic
B: static
C: local
D: constant

B: static

Which of the following built-in operations are valid for C++ class objects?

A: assignment and member access
B: arithmetic and assignment
C: relational and assignment
D: relational and member access

A: assignment and member access

The syntax for defining a class is ____.

A: class classIdentifier { class MembersList };
B: class classIdentifier ( class MembersList );
C: class classIdentifier [ class MembersList ];
D: returnType class classIdentifier { class MembersList };

A: class classIdentifier { class MembersList };

The word ____ at the end of a member function heading specifies that the function cannot modify the member variables of that object.

A: protected
B: private
C: public
D: const

D: const

Which of the following is true regarding parameter passing with class objects?

A: A class object may be passed by reference only.
B: A class object may be passed by value only.
C: A class object may be passed by reference or by value.
D: A class object may not be passed as a parameter.

C: A class object may be passed by reference or by value.

The general syntax for an object to access the members of its class is ____.

A: classObjectName(memberName)
B: classObjectName.memberName
C: classObjectName::memberName
D: classObjectName[memberName]

B: classObjectName.memberName

If a member of a class is a function, it can access ____.

A: member variables and member functions only if they are declared public
B: member functions only by using the scope resolution operator
C: member variables only by passing them as parameters
D: member variables and member functions directly

D: member variables and member functions directly

The components of a class are called ____.

A: indices
B: members
C: types
D: elements

B: members

In the function definition heading of a class, the function name consists of the class name, followed by the ____, followed by the function name.

A: member access specifier
B: scope resolution operator
C: member access operator
D: assignment operator

B: scope resolution operator

By default, all members of a class are ____.

A: static
B: private
C: protected
D: public

B: private

The syntax for declaring a class instance is ____.

A: class VariableName : classType;
B: classType = classVariableName;
C: classType (classVariableName);
D: classType classVariableName;

D: classType classVariableName;

A program or software that uses and manipulates the objects of a class is called a _____ of that class.

A: instance
B: mutator
C: accessor
D: client

D: client

The C++ class was designed specifically to ____.

A: allow for repetition
B: provide header and implementation files
C: group data and functions
D: provide iterative programming

C: group data and functions

If a member of a class is ____, you cannot access it outside the class.

A: static
B: public
C: private
D: constant

C: private

A class object is ____ if it is created each time the control reaches its declaration and destroyed when the control exits the surrounding block.

A: constant
B: global
C: static
D: automatic

D: automatic

In OOD, the first step is to identify the components, also called ____.

A: objects
B: functions
C: conditions
D: repetition structures

A: objects

Which of the following is true of C++ constructors?

A: They have a void type.
B: They have the same name as the class name.
C: Only one constructor is allowed in a class.
D: They can be called like other functions.

B: They have the same name as the class name.

In C++ terminology, a class variable is called a class object or class ____.

A: type
B: template
C: value
D: instance

D: instance

If a member function is used only to implement other member functions of a class and the user does not need to access the function, you should declare it ____.

A: const
B: static
C: private
D: public

C: private

In C++, class is a reserved word, and it defines only a(n) ____; no memory is allocated.

A: data type
B: object
C: member variable
D: member function

A: data type

Any class member that needs to be accessed outside of the class should be declared ____.

A: protected
B: public
C: private
D: static

B: public

If a class object is declared in a user program, then the object can access ____ of the class.

A: only the private members
B: only the public members
C: both the private and public members
D: None of the above

B: only the public members

To make a member of a class public, you use the member access specifier public with a ____.

A: colon
B: semicolon
C: comma
D: scope resolution operator

A: colon

A constructor without parameters is called a(n) ____ constructor.

A: global
B: type
C: default
D: empty

C: default

A class is a(n) ____ data type.

A: primitive
B: integral
C: simple
D: structured

D: structured

In ____ inheritance, a derived class is inherited from one than one base class.

A: complex
B: composite
C: multiple
D: abstract

C: multiple

Redefining a member function of a base class is also known as ____ the function.

A: overloading
B: protecting
C: overriding
D: specifying

C: overriding

All member variables of the base class are also member variables of the ____ class.

A: private
B: derived
C: overloaded
D: overriding

B: derived

____ classes are existing classes from which you derive new classes.

A: Composite
B: Concrete
C: Derived
D: Base

D: Base

To include a header file in a program, you use a(n) ____.

A: compiler directive
B: preprocessor command
C: executable program
D: user-defined file object

B: preprocessor command

Derived classes ____.

A: transfer their properties to base classes
B: inherit the properties of base classes
C: replace their base classes
D: cannot be base classes for other classes

B: inherit the properties of base classes

In ____, the data type is left unspecified and then later instantiated.

A: functional programming
B: parametric polymorphism
C: member instantiation
D: structured programming

B: parametric polymorphism

The private members of a base class ____.

A: can be inherited as private members of the derived class
B: can be directly accessed by derived classes
C: cannot be directly accessed by derived classes
D: can be inherited as public members of the derived class

C: cannot be directly accessed by derived classes

____ is the ability to use the same expression to denote different operations.

A: Inheritance
B: Composition
C: Encapsulation
D: Polymorphism

D: Polymorphism

The private members of a base class are hidden in the derived class if the base class is accessed with ____ inheritance.

A: private
B: public
C: protected
D: All of the above

D: All of the above

If a base class is accessed with private inheritance, ____.

A: the protected members of the base class are private members of the derived class
B: the public members of the base class are public members of the derived class
C: the protected members of the base class are
public members of the derived class
D: the public members of the base class are protected members of the derived class

A: the protected members of the base class are private members of the derived class

The class ofstream is directly derived from the class ____.

A: iostream
B: ostream
C: ifstream
D: ios

B: ostream

In OOD, a program is a collection of interacting ____.

A: functions
B: objects
C: modules
D: operations

B: objects

If a derived class overrides a public member function of the base class, you can call the base class function by using the ____.

A: function name, followed by a colon, followed by the base class name and appropriate parameter list
B: base class name, followed by a colon, followed by the function name and appropriate parameter list
C: base class name, followed by the scope resolution operator, followed by the function name and appropriate parameter list.
D: function name and the appropriate parameter list

C: base class name, followed by the scope resolution operator, followed by the function name and appropriate parameter list.

In ____ inheritance, a derived class is inherited from a single base class.

A: single
B: composite
C: simple
D: abstract

A: single

To trigger the execution of a constructor (with parameters) of the base class, you specify the name of a constructor of the base class with the parameters in _____.

A: the heading of the definition of the constructor of the base class
B: the heading of the definition of the destructor of the derived class
C: the heading of the definition of the constructor of the derived class
D: None of the above.

C: the heading of the definition of the constructor of the derived class

The class ____ is the base class for all C++ stream classes.

A: stream
B: istream
C: ios
D: iostream

C: ios

To include a system-provided header file, such as iostream, in a user program, you enclose the header file between ____.

A: double quotation marks
B: single quotation marks
C: parentheses
D: angular brackets

D: angular brackets

The general syntax of a derived class header definition is ____.

A: className: baseClassName
B: class className::baseClassName
C: class memberAccessSpecifier className: baseClassName
D: class className: memberAccessSpecifier baseClassName

D: class className: memberAccessSpecifier baseClassName

____ is a(n) "is a" relationship between classes.

A: Inheritance
B: Composition
C: Encapsulation
D: Polymorphism

A: Inheritance

A class can have a constructor with default parameters. Therefore, a ____ class can also have a constructor with default parameters.

A: overloaded
B: public
C: derived
D: private

C: derived

____ refers to the ability to combine data, and the operations on that data, in a single unit.

A: Inheritance
B: Composition
C: Encapsulation
D: Polymorphism

C: Encapsulation

____ classes are new classes that are created from existing classes.

A: Composite
B: Concrete
C: Derived
D: Base

C: Derived

When no member access specifier is included in a derived class header definition, it is assumed to be ____.

A: a private inheritance
B: a public inheritance
C: a protected inheritance
D: the same inheritance as the base class

A: a private inheritance

Which of the following is true of derived classes?

A: Derived classes can redefine the public members of the base class.
B: Derived classes cannot add their own member variables or functions.
C: Member functions of a base class are only members of a derived class if they are declared again.
D: A constructor of a derived class can directly access private members of the base class.

A: Derived classes can redefine the public members of the base class.

A call to the base class’s constructor is specified in the ____.

A: heading of the definition of the derived class constructor
B: definition of the derived class constructor
C: private declarations of the derived class
D: member function that first calls a base class member

A: heading of the definition of the derived class constructor

If a derived class does not override or overload a public member function of the base class, you can call the base class function by using the ____.

A: function name, followed by a colon, followed by the base class name and appropriate parameter list
B: base class name, following by a colon, followed by the function name and appropriate parameter list
C: base class name, followed by the scope resolution operator, followed by the function name and appropriate parameter list.
D: function name and the appropriate parameter list

D: function name and the appropriate parameter list

OOP terminology is influenced by the vocabulary of ____, the OOP language developed largely at the Xerox research center during the 1970’s.

A: Ada
B: Simula
C: Smalltalk
D: Java

C: Smalltalk

Note that the constructors of a base class are not inherited in a _____ class.

A: base
B: static
C: derived
D: None of the above.

C: derived

When the destructor of the derived class executes, it automatically invokes the destructor of the _____ class.

A: base
B: static
C: derived
D: parent

A: base

A common and simple technique to identify classes is to identify all the nouns and verbs in the description of the problem and from that list the ____ would be the classes.

A: nouns
B: verbs
C: nouns or verbs
D: None of the above.

A: nouns

The header file of a derived class ____ in a preprocessor directive.

A: does not need to include the header file of the base class
B: must include the header file of the base class
C: must include the implementation file of the base class
D: must include both the header and implementation files of the base class

B: must include the header file of the base class

If a base class is accessed with protected inheritance, ____.

A: the private members of the base class are public members of the derived class
B: the public members of the base class are public members of the derived class
C: the public members of the base class are protected members of the derived class
D: the protected members of the base class are public members of the derived class

C: the public members of the base class are protected members of the derived class

____ is a "has a" relationship between classes.

A: Inheritance
B: Composition
C: Encapsulation
D: Polymorphism

B: Composition

If a base class is accessed with public inheritance, ____.

A: the private members of the base class are public members of the derived class
B: the public members of the base class are public members of the derived class
C: the protected members of the base class are public members of the derived class
D: the protected members of the base class are public members of the derived class

B: the public members of the base class are public members of the derived class

Which of the following statements is true of derived class constructors?

A: A derived class can explicitly include its own constructors.
B: The constructors of a derived class can only directly initialize the public data members of the base class.
C: When a derived class object is declared, it must automatically execute one of the constructors of the base class.
D: All of the above

D: All of the above

The public members of a base class ____.

A: can only become private members of a derived class
B: can only become public members of a derived class
C: cannot become private members of a derived class
D: can become private or public members of a derived class

D: can become private or public members of a derived class

1- A ____ is a set of values of the same type.

a. set b. list c. dictionary d. map

1-B list

2- The ____ of a list is the number of elements in the list.

a. size b. capacity c. width d. volume

2-A size

3- The ____ search is called a linear search.

a. sequential b. binary c. selection d. bubble

3-A sequential

4- The sequential search starts with the element in ____ of the array.

a. position 0 b. position 1 c. the middle d. the last

4-A position 0

5- Consider the following list:
list = {20, 10, 17, 2, 18, 35, 30, 90, 48, 47};
Suppose that the sequential search is used to determine whether 2 is in the list. How many key comparisons are executed by the sequential search algorithm?

a. 3 b. 4 c. 8 d. 10

5-B 4

6- Consider the following list:
list = {20, 10, 17, 2, 18, 35, 30, 90, 48, 47};
Suppose that the sequential search is used to determine whether 95 is in the list. How many key comparisons are executed by the sequential search algorithm?

a. 5 b. 8 c. 10 d. 20

6-C 10

7- Item comparisons in the sequential search are also called ____ comparisons.

a. lock b. key c. record d. map

7-B key

8- Suppose that you have a list with 1000 elements. If the search item is not in the list, the sequential search makes ____ key comparisons.
a. 1 b. 500 c. 999 d. 1000

8-D 1000

9- In the ____ sort,
if list[index] is greater than list[index +1],
then the elements list[index]
and list[index +1] are swapped.

a. selection b. bubble c. binary d. insertion

9-B bubble

10- The code for the bubble sort function requires ____.
a. one if statement with one for loop inside
b. two if statements with a for loop inside the second if
c. two for loops and an if statement inside the second loop
d. two for loops with an if statement inside each loop

10-C two for loops and an if statement inside the second loop

11- Suppose that you have an unsorted list of 10 elements and the smallest element is at list[5]. After swapping using the selection algorithm, the smallest element is at position ____.

a. 0 b. 1 c. 9 d. 10

11-A 0

12- Consider the following list:
list = {24, 20, 10, 75, 70, 18, 60, 35};
Suppose that the list is sorted using the selection sort algorithm. What is the resulting list after two iterations of selection sort?
a. list = {10, 18, 24, 20, 75, 70, 60, 35}
b. list = {10, 18, 20, 24, 75, 70, 60, 35}
c. list = {10, 18, 24, 75, 70, 20, 60, 35}
d. list = {10, 18, 24, 75, 70, 20, 35, 60}

12-C list = {10, 18, 24, 75, 70, 20, 60, 35}

13- The code for sequential search of an ordered list contains a loop that stops (that is, found is set to true) if you find an element in the list that is ____ the item for which you are searching.
a. not equal to
b. greater than
c. either less than or equal to
d. either greater than or equal to

13-D either greater than or equal to

14 For an ordered list of 1000 elements (in the successful case), a sequential search, on average, makes ____ comparisons.

a. 500 b. 750 c. 1000 d. 2000

14-A 500

15- The binary search algorithm finds the middle element using which of the following formulas?
a. mid = first/last
b. mid = (last-first)/2
c. mid = first+last/2
d. mid = (first+last)/2

15-D mid = (first+last)/2

16- The first step in the binary search is to compare the search item with the element in ____ of the list.
a. position 0 b. position 1
c. the middle d. the last

16-C the middle

17- Suppose that L is a sorted list of 1000 elements. To determine whether the x item is in L, the maximum number of comparisons executed by the binary search algorithm is ____.

a. 1 b. 22 c. 42 d. 500

17-B 22

18- Suppose that L is a sorted list of 1,000,000 elements. To determine whether the x item is in L, the average number of comparisons executed by the sequential search algorithm is ____.

a. 220 b. 420 c. 500000 d. 1000000

18-C 500000

19- In general, if L is a sorted list of size n, to determine whether an element x is in L, the binary search makes at most ____ key comparisons.
a. 2 * log2n
b. log2n + 2
c. 2 * log2n
d. 2 * log2n + 2

19-D 2 * log2n + 2

20- Which statement creates the vector object, vecList, of size n and initializes using n copies of the element elem?
a. vector vecList(n, elem);
b. vector &lt; elementType &gt; vecList(n) = elem;
c. vector &lt; elemType &gt; vecList(n, elem);
d. vector &lt; elementType &gt; vecList(elem)(n);

20-C vector < elemType > vecList(n, elem);

21- Which of the following is a valid declaration?
a. vector intList(10);
b. &lt; int &gt; vector intList(10);
c. vector &lt; int &gt; int(10);
d. vector &lt; int &gt; intList(10);

21-D vector < int > intList(10);

22- The ____ operation on the vector object vecList returns the last element of vecList.
a. vecList.front()
b. vecList.back()
c. vecList.at()
d. vecList.push_back()

22-B vecList.back()

23 – The ____ operation on the vector object vecList returns the first element of vecList.
a. vecList.front()
b. vecList.first()
c. vecList.pop_front()
d. vecList.push_front()

23-A vecList.front()

24- Which of the following statements declares list to be an empty vector object? a. vector &lt; int &gt; list; b. vector &lt; int &gt; list(); c. &lt; int &gt; vector list; d. vector &lt; int &gt; list(0);

24-A vector < int > list;

25- The ____ operation on a vector object changes the size of vecList to n.
a. vecList.change_size(n)
b. vecList.increase(n)
c. vecList.size(n)
d. vecList.resize(n)

25-D vecList.resize(n)

26- A struct is a ____ data structure.
a. simple b. dynamic
c. heterogeneous d. linked

26-C heterogeneous

27- The components of a struct are called the ____ of the struct.
a. variables b. identifiers
c. elements d. members

27-D members

28 – Which of the following struct definitions is correct in C++?
a. struct studentType
{
int ID;
};
b. struct studentType
{
string name;
int ID;
double gpa;
}
c. int struct studentType
{
ID;
}
d. struct studentType
{
int
ID
};

28-A struct studentType { int ID; };

29- Consider the following struct definition
struct rectangleData
{ double length;
double width;
double area;
double perimeter;
};
Which of the following variable declarations is correct?
a. rectangle rectangleData;
b. struct rectangleData();
c. rectangleData myRectangle;
d. rectangleData rectangle = new rectangleData();

29-C rectangleData myRectangle;

30- Typically, in a program, a struct is defined ____ in the program.

a. in the main function
b. before the definitions of all the functions
c. after the definitions of all the functions
d. in any function

30-B- before the definitions of all the functions

31- An array name and index are separated using ____.

a. curly brackets
b. square brackets
c. a dot
d. a comma

31-B square brackets

32- The syntax for accessing a struct member is structVariableName____.
a. .memberName
b. *memberName
c. [memberName]
d. $memberName

32-A .memberName

33- Consider the following statements.
struct rectangleData
{
double length;
double width;
double area;
double perimeter;
};
rectangleData bigRect;
Which of the following statements correctly initializes the component length of bigRect?
a. bigRect = {10};
b. bigRect.length = 10;
c. length[0]= 10;
d. bigRect[0]= 10

33-B bigRect.length = 10;

34- In C++, the ____ symbol is an operator, called the member access operator.
a. :(colon) b. .(dot)
c. ,(comma) d. $ (dollar sign)

34-B .(dot)

35- Consider the following statements.
struct rectangleData
{
double length;
double width;
double area;
double perimeter;
};
rectangleData bigRect;
Which of the following statements is valid in C++?
a. cin &gt;&gt; bigRect;
b. cin &gt;&gt; bigRect.length;
c. perimeter = 2 * (length + width);
d. area = length * width;

35-B cin >> bigRect.length;

36 Consider the following statements.
struct rectangleData
{ double length;
double width;
double area;
double perimeter;
};
rectangleData bigRect;
Which of the following statements is valid in C++?
a. cin &gt;&gt; bigRect.length &gt;&gt; width;
b. cout &lt;&lt; bigRect.length;
c. cout &lt;&lt; bigRect;
d. cout &lt;&lt; length;

36-B cout << bigRect.length;

37 Consider the following statements.
struct circleData
{
double radius;
double area;
double circumference;
};
circleData circle;
Which of the following statements is valid in C++?
a. cin &gt;&gt; circle.radius; circle.area = 3.14 <b> radius </b> radius;
b. cin &gt;&gt; circle.radius; circle.area = 3.14 <b> circle.radius </b> radius;
c. cin &gt;&gt; circle;
d. cin &gt;&gt; circle.radius;

37-D cin >> circle.radius;

38 Consider the following statements.
struct personalInfo
{
string name;
int age;
double height;
double weight;
};
struct commonInfo
{
string name;
int age;
};
personalInfo person1, person2;
commonInfo person3, person4; Which of the following statements is valid in C++?
a. person1 = person3;
b. person2 = person1;
c. person2 = person3;
d. person2 = person4;

38-B person2 = person1;

39 Consider the following statements.
struct studentType1
{
string name;
int ID;
double gpa;
};
studentType1 student1, student2;
struct studentType2
{
string name;
int ID;
double gpa; };
studentType2 student3, student4;
Which of the following statements is valid in C++?
a. student2 = student3;
b. student1 = student4;
c. student2.ID = ID;
d. student1.ID = student3.ID;

39-D student1.ID = student3.ID;

40 You can assign the value of one struct variable to another struct variable of ____ type(s).
a. any b. the same
c. a different d. a heterogeneous

40-B by value

41 To compare struct variables, you compare them ____.
a. by reference b.by value
c.index-wise d.member-wise

41-D member-wise

42 Consider the following statements.
struct rectangleData
{
double length;
double width;
double area;
double perimeter;
};
rectangleData bigRect;
rectangleData smallRect;

Which of the following statements is legal in C++?
a. if (bigRect == smallRect)
b. if (bigRect != smallRect)
c. if (bigRect.length == width)
d. if (bigRect.length == smallRect.width)

42-D if (bigRect.length == smallRect.width)

43 A struct variable can be passed as a parameter ____.

a. only by const
b. only by reference
c. only by value
d. either by value or by reference

43-D either by value or by reference

44 Which of the following aggregate operations can be executed on array variables?

a. Arithmetic
b. Assignment
c. Comparison
d. Parameter passing

44-D Parameter passing

45 Which of the following is an allowable aggregate operation on a struct?

a. Arithmetic
b. Assignment
c. Input/output
d. Comparison

45-B Assignment

46 A list has two items associated with it: ____.

a. the length and the references
b. the values and the references
c. the indexes and the length
d.the values and the length

46-D the values and the length

47 Consider the following function prototype.
int seqSearch(const listType&amp; list, int searchItem);
The ____ cannot modify the actual parameter.
a. seqSearch
b. listType
c. list
d. searchItem

47-C list

48 Consider the following statements.
struct supplierType
{
string name;
int supplierID;
};
struct applianceType
{
supplierType supplier;
string modelNo;
double cost;
};
applianceType applianceList[25];

Which of the following best describes applianceList?
a. It is an array.
b. It is a struct.
c. It is an array of structs.
d. It is a struct of arrays.

48-C It is an array of structs.

49 Consider the following statements.
struct supplierType
{
string name;
int supplierID;
};
struct applianceType
{
supplierType supplier;
string modelNo;
double cost;
};
applianceType applianceList[25];

Which of the following statements correctly initializes the cost of each appliance to 0?
a. applianceList.cost = 0;
b. applianceList.cost[25] = 0;
c. for (int j = 1; j &lt; 25; j++) applianceList.cost[j] = 0;
d. for (int j = 0; j &lt; 25; j++) applianceList.cost[j] = 0;

49-D for (int j = 0; j < 25; j++) applianceList.cost[j] = 0;

50 Consider the following statements.
struct supplierType
{
string name;
int supplierID;
};
struct paintType
{ supplierType supplier;
string color;
string paintID;
};
paintType paint;
What is the data type of paint.supplier?
a. string
b. paintType
c. supplierType
d. struct

50-C supplierType

51 The components of a class are called the ____ of the class.
a. elements
b. members
c. objects
d. properties

51-B members

52 Which of the following class definitions is correct in C++?
a. class studentType
{
public:
void setData(string, double, int);
private:
string name;
};
b. class studentType
{
public:
void setData(string, double, int);
void print() const;
private:
string name;
double gpa;
}
c. class studentType
{
public void setData(string, double, int);
private string name;
};
d. studentType class
{
public: void setData(string, double, int);
private: string name;
};

52-A class studentType { public: void setData(string, double, int); private: string name; };

53 If a member of a class is ____, you cannot access it outside the class.
a. public
b. automatic
c. private
d. static

53-C private

54 A class and its members can be described graphically using a notation known as the ____ notation.
a. OON
b. OOD
c. UML
d. OOP

54-C UML

clockType
-hr: int
-min: int
-sec: int___________________
+setTime(int, int, int): void
+getTime(int&amp;, int&amp;, int&amp;) const: void
+printTime() const: void
+incrementSeconds(): int
+incrementMinutes(): int
+incrementHours(): int
+equalTime(const clockType&amp;) const: bool
55 The word ____ at the end of the member functions in the class clockType specifies that these functions cannot modify the member variables of a clockType object.
a. static
b. const
c. automatic
d. private

55-B const

56 Consider the UML class diagram shown in the accompanying figure. Which of the following is the name of the class?
a. clock
b. clockType
c. Type
d. +clockType

56-B clockType

57 Consider the UML class diagram shown in the accompanying figure. According to the UML class diagram, what is the number of private members of the class?

a. 0 b. 1 c. 2 d. 3

57-D 3

58 A ____ sign in front of a member name on the UML diagram indicates that this member is a public member.

a. + b. – c. # d. $

58-A +

59 A ____ sign in front of a member name on the UML diagram indicates that this member is a private member.

a. + b. – c. # d. $

59-B –

60 A ____ sign in front of a member name on the UML diagram indicates that this member is a protected member.

a. + b. – c. # d. $

60-C #

class rectangleType
{
public:
void setLengthWidth(double x, double y);
//Postcondition: length = x; width = y;
void print() const;
//Output length and width;
double area();
//Calculate and return the area of the rectangle;
double perimeter();
//Calculate and return the parameter;
rectangleType();
//Postcondition: length = 0; width = 0;
rectangleType(double x, double y);
//Postcondition: length = x; width = y;
private:
double length;
double width;
};
61 Consider the accompanying class definition. Which of the following class variable declarations is correct?
a. rectangle rectangleType;
b. class rectangleType rectangle;
c. rectangleType rectangle;
d. rectangle rectangleType.area;

61-C rectangleType rectangle;

62 Consider the accompanying class definition, and the declaration:

rectangleType bigRect;

Which of the following statements is correct?
a. rectangleType.print();
b. rectangleType::print();
c. bigRect.print();
d. bigRect::print();

62-C bigRect.print();

63 Consider the accompanying class definition, and the object declaration:

rectangleType bigRect(14,10);

Which of the following statements is correct?
a. bigRect.setLengthWidth();
b. bigRect.setLengthWidth(3.0, 2.0);
c. bigRect.length = 2.0;
d. bigRect.length = bigRect.width;

63-B bigRect.setLengthWidth(3.0, 2.0);

64 In C++, the ____ is an operator called the member access operator.

a. . b. , c. :: d. #

64-A .

65 A class object can be ____; that is, it is created each time control reaches its declaration, and destroyed when the control exits the surrounding block.
a. static
b. automatic
c. local
d. public

65-B automatic

66 A class object can be ____; that is, it can be created once, when the control reaches its declaration, and destroyed when the program terminates.

a. static
b. automatic
c. local
d. public

66-A static

67 In C++, you can pass a variable by reference and still prevent the function from changing its value, by using the keyword ____ in the formal parameter declaration.
a. automatic
b. private
c. static
d. const

67-D const

68 In C++, the scope resolution operator is ____.

a. : b. :: c. $ d. .

68-B ::

69 A member function of a class that only accesses the value(s) of the data member(s) is called a(n) ____ function.

a. accessor
b. mutator
c. constructor
d. destructor

69-A accessor

70 To guarantee that the member variables of a class are initialized, you use ____.
a. accessors
b. mutators
c. constructors
d. destructor

70-C constructors

class secretType
{
public:
static int count;
static int z;

secretType();
secretType(int a);
void print();
static void incrementY();

private:
int x;
static int y;
};

secretType::secretType()
{
x = 1;
}

secretType::secretType(int a)
{
x = a;
}

void secretType::print()
{
cout &lt;&lt; "x = " &lt;&lt; x &lt;&lt; ", y = " &lt;&lt; y
&lt;&lt; "z = " &lt;&lt; z
&lt;&lt; ", count = " &lt;&lt; count &lt;&lt; endl;
}
static void secretType::incrementY()
{
y++;
}

71 Consider the accompanying class and member functions definitions. How many constructors are present in the class definition above?

a. 0 b. 1 c. 2 d. 3

71-C 2

72 Consider the accompanying class and member functions definitions. Which of the following statements correctly creates the object mySecret of type secretType and sets the value of the member variable x to 9?
a. secretType mySecret(9);
b. mySecret = secretType(9);
c. secretType = mySecret(9);
d. secretType(9).mySecret;

72-A secretType mySecret(9);

73 How many destructors can a class have?

a. 0 b. 1 c. 2 d. Any number

73-B 1

74 The name of a destructor is the character ‘____’, followed by the name of the class.

a. . b. :: c. # d. ~

74-D ~

75 What does ADT stand for?

a. abstract definition type
b. asynchronous data transfer
c. abstract data type
d. alternative definition type

75-C abstract data type

76 Which of the following is true about classes and structs?

a. By default, all members of a struct are public and all members of a class are private.
b. A struct variable is passed by value only, and a class variable is passed by reference only.
c. An assignment operator is allowed on class variables, but not on struct variables.
d. You cannot use the member access specifier private in a struct.

76-A By default, all members of a struct are public and all members of a class are private.

77 A C++ implementation file has the extension ____.

a. .imp b. .h c. .exe d. .cpp

77-D .cpp

78 If a function of a class is static, it is declared in the class definition using the keyword static in its ____.

a. return type
b. parameters
c. heading
d. main function

78-C heading

79 Inheritance is an example of what type of relationship?

a. is-a
b. has-a
c. was-a
d. had-a

79-A is-a

80 ____ is an "is-a" relationship.

a. Inheritance
b. Encapsulation
c. Composition
d. Polymorphism

80-A Inheritance

81 ____ is a "has-a" relationship.

a. Inheritance
b. Encapsulation
c. Composition
d. Polymorphism

81-C Composition

82 The new classes that we create from existing classes are called ____ classes.

a. sibling
b. base c.
derived
d. parent

82-C derived

83 Existing classes, from which you create new classes, are called ____ classes.

a. child
b. base
c. sibling
d. derived

83-B base

84 Suppose that bClass is a class. Which of the following statements correctly derives the class dClass from bClass?
a. class dClass:: public bClass
{
//classMembersList
};
b. class dClass: private bClass
{
//classMembersList
};
c. class dClass:: protected bClass
{
//classMembersList
};
d. class bClass: public dClass
{
//classMembersList
};

84-B class dClass: private bClass { //classMembersList };

85 Consider the following class definition.
class dClass: bClass
{
//class members list
};
The class dClass is derived from the class bClass using the ____ type of inheritance.

a. public
b. private
c. protected
d. static

85-B private

86 Which of the following is a valid definition of the derived class bClass?
a. class aClass: public bClass
{
// …
};
b. class bClass: public aClass
{
// …
};
c. class aClass::bClass
{
// …
};
d. class bClass::aClass
{
// …
}

86-B class bClass: public aClass { // … };

87 Which of the following is true about inheritance?

a. All public member functions of the base class become the public member functions of the derived class.
b. All public member variables of the base class become the public member variables of the derived class.
c. All public members of the base class become the public members of the derived class.
d. The public member variables of the base class become the public or private member variables of the derived class.

87-D The public member variables of the base class become the public or private member variables of the derived class.

88 Which of the following class definitions makes the public members of the class aClass become the public members of the class bClass?
a. class aClass: public bClass
{
//…
};
b. class bClass: public aClass
{
//…
};
c. class bClass: aClass
{
//
};
d. class aClass: bClass
{
//…
};

88-B class bClass: public aClass { //… };

89 Which of the following is true about a derived class?
a. A derived class can directly access any member variable of the base class.
b. A derived class can redefine any public member function of the base class.
c. A derived class can have at most one base class.
d. A derived class can redefine any member function of the base class.

89-B A derived class can redefine any public member function of the base class.

90 To ____ a public member function of a base class in the derived class, the corresponding function in the derived class must have the same name, number, and types of parameters.
a. redefine
b. overload
c. rename
d. reuse

90-A redefine

91 If the corresponding functions in the base class and the derived class have the same name but different sets of parameters, then this function is ____ in the derived class.
a. reused
b. redefined
c. overloaded
d. overridden

91-C overloaded

92 Consider the following class definitions.
class bClass
{
public:
void setX(int);
oid print() const;

private:
int x;
};

class dClass: public bClass
{
public:
void setXY(int, int);
void print() const;

private: int y;
};
Which of the following statements correctly redefines the member function print of bClass?
a. void dClass::print() const
{
dClass:print();
cout &lt;&lt; " " &lt;&lt; y &lt;&lt; endl;
}
b. void dClass::print() const
{
cout &lt;&lt; x &lt;&lt; " " &lt;&lt; y &lt;&lt; endl;
}
c. void bClass::print() const
{
cout &lt;&lt; x &lt;&lt; " " &lt;&lt; y &lt;&lt; endl;
}
d. void dClass::print() const
{
bClass::print();
cout &lt;&lt; "y = " &lt;&lt; y &lt;&lt; endl;
}

92-D void dClass::print() const { bClass::print(); cout << "y = " << y << endl; }

93 Consider the following class definitions.
class bClass
{
public: void setX(int a);
//Postcondition: x = a;
void print() const;

private: int x;
};
class dClass: public bClass
{
public:
void setXY(int a, int b);
//Postcondition: x = a; y = b;
void print() const;

private:
int y;
};

Which of the following correctly sets the values of x and y?
a. void dClass::setXY(int a, int b)
{
bClass::setX(a);
y = b;
}
b. void dClass::setXY(int a, int b)
{
x = a;
y = b;
}
c. void dClass::setXY(int a, int b)
{
x = bClass::setX(a);
y = bClass::setY(b);
}
d. void dClass::setXY(int a, int b)
{
x = bClass.setX(a);
b = y;
}

93-A void dClass::setXY(int a, int b) { bClass::setX(a); y = b; }

94 If the derived class classD overrides a public member function functionName of the base class classB, then to specify a call to that public member function of the base class you use the ____ statement.
a. classD::functionName();
b. classB::functionName();
c. classD.functionName();
d. classB.functionName();

94-B classB::functionName();

95 Consider the following class definitions.
class bClass
{
public:
void set(double a, double b); //Postcondition: x = a;
y = b;
void print() const;
bClass();
//Postcondition: x = 0;
y = 0;
bClass(double a, double b);
//Postcondition: x = a;
y = b;

private:
double x;
double y;
};
class dClass: public bClass
{
public:
void set(double a, double b, double c);
//Postcondition: x = a; y = b; z = c;
void print() const;
dClass();
//Postcondition: x = 0;
y = 0;z = 0 ; dClass(double a, double b, double c);
//Postcondition: x = a;
y = b;
z = c;
private:
double z;
};

Which of the following dClass constructor definitions is valid in C++?
a. dClass::dClass(double a, double b, double c)
: bClass()
{
x = a;
y = b;
z = c;
}
b. dClass::dClass(double a, double c)
{
x = a;
z = c;
}
c. dClass::dClass(double a, double b)
: bClass()
{
x = a;
y = b;
}
d. dClass::dClass(double a, double b, double c)
: bClass(a, b)
{
z = c;
}

95-D dClass::dClass(double a, double b, double c) : bClass(a, b) { z = c; }

96 What is the output of the following program?
#include &lt; iostream &gt;
using namespace std;
class bClass
{
public:
void print() const;
bClass(int a = 0, int b = 0);
//Postcondition: x = a; y = b;

private:
int x;
int y;
};

class dClass: public bClass
{
public:
void print() const;
dClass(int a = 0, int b = 0, int c = 0);
//Postcondition: x = a; y = b; z = c;

private:
int z;
};

int main()
{
bClass bObject(2, 3);
dClass dObject(3, 5, 8);
bObject.print();
cout &lt;&lt; endl;
dObject.print();
cout &lt;&lt; endl;

return 0 ;
}
void bClass::print() const
{
cout &lt;&lt; x &lt;&lt; " " &lt;&lt; y &lt;&lt; endl;
}
bClass::bClass(int a, int b)
{
x = a;
y = b;
}
void dClass::print() const
{
bClass:print();
cout &lt;&lt; " " &lt;&lt; z &lt;&lt; endl;
}

dClass::dClass(int a, int b, int c)
: bClass(a, b)
{
z = c;
}

a. 2 3 2 3
b. 2 3 3 5 8
c. 3 5 8 3 5 8
d. 5 8 3 5 8

96-B 2 3 3 5 8

97 Which of the following statements about inheritance is true if memberAccessSpecifier is protected?
a. The private members of the base class become protected members of the derived class.
b. The derived class can directly access any member of the base class.
c. The public members of the base class become protected members of the derived class.
d. The protected members of the base class become private members of the derived class.

97-C The public members of the base class become protected members of the derived class.

98 ____ is the ability to combine data, and operations on that data, in a single unit.
a. Inheritance
b. Encapsulation
c. Polymorphism
d. Composition

98-B Encapsulation

99 ____ is the ability to use the same expression to denote different operations.
a. Inheritance
b. Encapsulation
c. Polymorphism
d. Composition

99-C Polymorphism

100 OOP implements ____.
a. UML
b. IPE
c. EIP
d. OOD

100-D OOD

101 C++ provides ____ functions as a means to implement polymorphism in an inheritance hierarchy, which allows the run-time selection of appropriate member functions.

a. redefined
b. overridden
c. virtual
d. overloaded

101-C virtual

102 The ____ members of an object form its internal state.

a. private
b. protected
c. public
d. static

102-A private

103 The ____ members of an object form its external state.

a. private
b. public
c. protected
d. static

103-B public

The size of a ____ array is fixed at compile time.

A: dynamic
B: static
C: pointer
D: all of the above

B: static

Given the statements: int x; int *p; the statement: p = &amp;x;

A: assigns the address of x to p
B: assigns the value of x to p
C: assigns the address of x to the address of p
D: assigns the value of x to the address of p

A: assigns the address of x to p

C++ allows the user to pass an object of a _____ class to a formal parameter of the base class type.

A: static
B: abstract
C: parent
D: derived

D: derived

In C++, the ____ operator returns the address of its operand.

A: %
B: @
C: &amp;
D: *

C: &

The constant value 0 is known as the ____.

A: initializer
B: null pointer
C: void pointer
D: empty address

B: null pointer

Some programmers use the named constant ____ to initialize pointer variables.

A: ZERO
B: EMPTY
C: VOID
D: NULL

D: NULL

Variables that are created during program ____ are called dynamic variables.

A: execution
B: compilation
C: linking
D: building

A: execution

Which of the following is a valid pointer declaration?

A: int *p;
B: int* p;
C: int * p;
D: all of the above

D: all of the above

Given an pointer p of type double, the statement p++; increments the value of p by ____ bytes.

A: 1
B: 2
C: 4
D: 8

D: 8

In C++, a pointer ____.

A: cannot be passed as a parameter to a function
B: can be passed as a value or reference parameter
C: can be passed as a reference parameter only
D: can be passed as a value parameter only

B: can be passed as a value or reference parameter

Unused memory space that cannot be allocated is referred to as a(n) _____.

A: void area
B: memory leak
C: garbage space
D: heap

B: memory leak

Which of the following operators is used as both a binary and unary operator in C++?

A: &amp;
B: *
C: /
D: %

B: *

A declaration such as: int *p; allocates memory for ____.

A: p only
B: *p only
C: both p and *p
D: none of the above

A: p only

To create a dynamic array, use a form of the ____ operator.

A: delete
B: dynamic
C: new
D: array

C: new

When you declare a pointer variable, you specify the ____ of the value to be stored in the memory location.

A: range
B: name
C: data type
D: identifier

C: data type

Which of the following statements creates a two-dimensional dynamic array of four pointers in which each pointer is of type int?

A: int* [4] arrayName;
B: int arrayName[4];
C: int *arrayName[4];
D: int [4] *arrayName;

C: int *arrayName[4];

Which of the following is the correct syntax for accessing a member variable of a class with a pointer of that class type?

A: *pointerVariableName.classMemberName
B: (*pointerVariableName).classMemberName
C: pointerVariableName.classMemberName
D: pointerVariableName.(*classMemberName)

B: (*pointerVariableName).classMemberName

To simplify the accessing of a class or struct with a pointer, C++ provides the ____.

A: address of operator
B: indirection operator
C: member access operator arrow
D: dot operator

C: member access operator arrow

____ are the domain of pointer variables.

A: Memory addresses
B: Numbers
C: Classes
D: Simple types

A: Memory addresses

An array created during the execution of a program is called a ____ array.

A: static
B: temporary
C: dynamic
D: fixed

C: dynamic

In C++, you declare a pointer variable by using a(n) ____.

A: double colon
B: set of angular brackets
C: ampersand
D: asterisk

D: asterisk

There is no ____ associated with a pointer data type in C++.

A: syntax
B: type
C: name
D: address

C: name

When a program no longer needs a dynamic variable, the operator ____ is used.

A: erase
B: void
C: -&gt;
D: delete

D: delete

Given the statements: int x = 25; int <b>p; p = &amp;x; </b>p = 55; the value of x after the statements have executed is ____.

A: p
B: 25
C: 55
D: *p

C: 55

Which of the following is the general syntax for accessing a member variable using the operator -&gt;?

A: pointerVariableName-&gt;classMemberName
B: *pointerVariableName-&gt;classMemberName
C: pointerVariableName-&gt;*classMemberName
D: classMemberName-&gt;pointerVariableName

A: pointerVariableName->classMemberName

The operator delete has _____ form(s).

A: one
B: two
C: three
D: four

B: two

The syntax to use the operator new to allocate a single variable is ____.

A: new dataType;
B: new dataType();
C: dataType.new;
D: new *dataType;

A: new dataType;

The syntax to use the operator new to allocate an array of variables is ____.

A: new dataType(intExp);
B: new dataType[intExp];
C: dataType.new(intExp);
D: new *dataType[intExp];

B: new dataType[intExp];

The dereferencing operator is also known as the ____ operator.

A: extraction
B: access
C: address
D: indirection

D: indirection

A pointer variable is a variable ____.

A: whose content is an address
B: that is a structured type
C: that stores the int data type
D: whose value refers to a class

A: whose content is an address

C++ data types are classified into three categories: ____.

A: number, string, and pointer
B: simple, structured, and pointer
C: simple, struct, and pointer
D: pointer, struct, and class

B: simple, structured, and pointer

Which of the following is true regarding the statement int* p, q;?

A: only p is a pointer variable
B: p and q are pointer variables
C: the statement is invalid
D: p and q are the same data type

A: only p is a pointer variable

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

A: virtual
B: run-time
C: dynamic
D: static

D: static

In a shallow copy, ____.

A: two or more pointers of the same type point to the same memory location
B: two or more pointers of the same type point to different memory locations
C: two or more pointers of differing types point to the same memory location
D: the values of two or more pointers are copied into a list

A: two or more pointers of the same type point to the same memory location

The ____ operator in C++ refers to the object to which its operand points.

A: address of
B: extraction
C: dereferencing
D: direction

C: dereferencing

When an integer is subtracted from a pointer variable, the value of the pointer variable is decremented by ____.

A: the integer times the size of the memory to which the pointer is pointing
B: the integer
C: the size of the memory to which the pointer is pointing
D: the integer plus the size of the memory to which the pointer is pointing

A: the integer times the size of the memory to which the pointer is pointing

A dynamic variable is accessed ____.

A: indirectly by the pointer returned by new
B: by name
C: by the member access operator
D: by the address of operator

A: indirectly by the pointer returned by new

Which of the following operations is allowed on pointer variables?

A: equality
B: addition
C: assignment
D: all of the above

D: all of the above

The set of values belonging to a data type is called the ____ of the data type.

A: range
B: list
C: class
D: domain

D: domain

The operator new has ____ form(s).

A: one
B: two
C: three
D: four

B: two

Share This
Flashcard

More flashcards like this

NCLEX 10000 Integumentary Disorders

When assessing a client with partial-thickness burns over 60% of the body, which finding should the nurse report immediately? a) ...

Read more

NCLEX 300-NEURO

A client with amyotrophic lateral sclerosis (ALS) tells the nurse, "Sometimes I feel so frustrated. I can’t do anything without ...

Read more

NASM Flashcards

Which of the following is the process of getting oxygen from the environment to the tissues of the body? Diffusion ...

Read more

Unfinished tasks keep piling up?

Let us complete them for you. Quickly and professionally.

Check Price

Successful message
sending