Ch 11

25 July 2022
4.7 (114 reviews)
46 test answers

Unlock all answers in this set

Unlock answers (42)
question
A struct can contain members with varying data types.
answer
T
question
Any mathematical operation that can be performed on regular C++ variables can be performed on structure members.
answer
T
question
Structure variables may be passed as arguments to functions.
answer
T
question
The structure pointer operator is used to dereference a pointer to a structure, not a pointer that is a member of a structure.
answer
T
question
If a function is legally prototyped to return an integer value, it can return a structure member that is an integer data type.
answer
T
question
A function cannot modify the members of a structure.
answer
F
question
The expression s->m; indicates that s is a structure pointer and m is a structure member.
answer
T
question
It is possible to output the contents of all members of a structure variable using a cout << statement followed by the name of the structure variable.
answer
F
question
When a programmer creates an abstract data type, he or she can decide what values are acceptable for the data type, as well as what operations may be performed on the data type.
answer
T
question
It is possible for a structure variable to be a member of another structure variable.
answer
T
question
The expression *s->p; indicates that s is a structure pointer and p, which is also a pointer, is a member of the structure pointed to by s.
answer
T
question
It is possible for a structure to contain, as a member, a pointer to its own structure type.
answer
T
question
You cannot directly assign an integer value to an enum variable.
answer
T
question
You cannot directly assign an enumerator to an int variable.
answer
F
question
When you use a strongly typed enumerator in C++11 you must prefix the enumerator with the name of the enum followed by the :: operator.
answer
T
question
The names of enumerators in an enumerated data type must be enclosed in quotation marks.
answer
F
question
In C++11 if you want to retrieve a strongly typed enumerator's underlying integer value, you must use a cast operator.
answer
T
question
Given the structure definition shown, assume that circle1 and circle2 are variables of the Circle type and their members have been initialized. struct Circle { double centerX; double centerY; double radius; }; Then, is it true or false that the following statement correctly determines whether the two variables' members contain the same data? if (circle1 == circle2)
answer
F
question
Which of the following describes only the general characteristics of an object? a. initialization b. abstraction c. detailed specification d. initiation e. None of these
answer
B
question
Which of the following is required after the closing brace of the structure definition? a. square bracket b. period c. semicolon d. colon e. None of these
answer
C
question
Which of the following is an example of a C++ primitive data type? a. unsigned short int b. long double c. unsigned char d. All of these e. None of these
answer
D
question
The following statement __________. bookList[2].publisher[3] = 't'; a. is illegal in C++ b. will change the name of the second book in bookList to 't' c. will store the character 't' in the fourth element of the publisher member of bookList[2] d. will result in a runtime error e. None of these
answer
C
question
When a structure is passed __________ to a function, its members are not copied. a. by reference b. by value c. Either of these d. Neither of these
answer
A
question
Passing a structure as a constant reference parameter to a function a. can potentially result in changes to the structure's members b. guarantees not to result in changes to the structure's members c. will always change the structure's members d. None of these
answer
B
question
You may use a pointer to a structure as a a. function parameter b. structure member c. function return type d. All of these e. None of these
answer
D
question
Data types that are created by the programmer are known as a. variables b. abstract data types (ADTs) c. functions d. parameters e. None of these
answer
B
question
Before a structure can be used it must be a. declared b. dereferenced c. initialized d. All of these e. None of these
answer
A
question
The name of a structure is referred to as its a. data type b. argument c. parameter d. tag e. None of these
answer
E
question
A function __________ return a structure. a. may b. may not c. will always d. can never e. None of these
answer
A
question
A structure pointer contains a. the address of a structure variable b. the dereferenced address of a structure tag c. the name and address of the structure tag d. the address of a structure tag e. None of these
answer
A
question
Which of the following assigns a value to the hourlyWage member of employee[2]? a. employee[2] -> hourlyWage = 50.00; b. employee2.hourlyWage = 7.50; c. hourlyWage[2].employee = 29.75; d. employee[2].hourlyWage = 75.00; e. None of these
answer
D
question
If Circle is a structure tag, then the following statement can be the header line for a function that __________. Circle doSomething(Circle c2) a. determines and returns the area of a circle b. takes a Circle structure as a parameter, does something, and returns a Circle structure c. operates on a constant reference to a Circle structure d. takes two Circle parameters and does something e. None of these
answer
B
question
Which of the following will allow you to access structure members? a. the structure access operator b. the dot operator c. the #include directive d. the getmember function e. None of these
answer
B
question
To dereference a structure pointer, the appropriate operator is a. the ampersand (&) b. an asterisk (*) c. the -> operator d. the <- operator (<-) e. None of these
answer
C
question
If a is a structure variable and p, a pointer, is a member of the structure, what will the following statement do? cout << *a.p; a. output the dereferenced value pointed to by p b. result in a compiler error c. output the address stored in p d. output the value stored in a e. None of these
answer
A
question
A structure __________ contain members of the same data type. a. cannot b. can c. shouldn't d. None of these
answer
B
question
Which of the following statements outputs the value of the gpa member of element [1] of the student array? a. cout << student1.gpa; b. cout << firstStudent.gpa; c. cout << student[1].gpa; d. cout << student1->gpa; e. None of these
answer
C
question
If Circle is a structure, what does the following statement do? Circle *pcirc = nullptr; a. It declares an empty structure variable named *pcirc. b. It declares a structure pointer called pcirc initialized with a null pointer. c. The statement is illegal in C++. d. It initializes a null pointer with the value of the Circle pointer. e. None of these
answer
B
question
A good reason to pass a structure as a constant reference is a. to prevent changes to the structure's members b. to ensure changes to the structure's members c. to slow down the function's execution which helps prevent errors d. to speed up the function's modification of the structure's members e. None of these
answer
A
question
With an enumerated data type, the enumerators are stored in memory as a. strings b. integers c. characters d. doubles
answer
B
question
In C++11, you can use a new type of enum known as a(n) __________ (also known as an enum class) to have multiple enumerators with the same name, within the same scope. a. universal enum b. auto enum c. multi-cast enum d. strongly typed enum e. None of these
answer
D
question
A declaration for an enumerated type begins with the __________ key word. a. enumerated b. enum_type c. enum d. ENUM e. None of these
answer
C
question
After the following statement executes, what value will the MAPLE enumerator be stored as, in memory? enum Tree { OAK, MAPLE, PINE }; a. "MAPLE" b. 2 c. 'M' d. 1 e. 1.0
answer
D
question
Given the following decaration: enum Tree { OAK, MAPLE, PINE }; What is the value of the following relational expression? OAK > PINE a. true b. false c. This is an error. You cannot compare enumerators with relational operators.
answer
B
question
Given the following structure decaration, Employee is struct Employee { string name; int idNum; }; a. a member b. an array c. a tag d. None of these
answer
C
question
Given the following structure decaration, idNum is struct Employee { string name; int idNum; }; a. a member b. an array c. a tag d. None of these
answer
A