Chapter 11 study bank

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

30) Look at the following structure declaration. ​struct Employee ​{ ​ string name; ​ int idNum; ​}; In this declaration, Employee is: A) a member B) an array C) a tag D) None of these Answer: C

A member

) 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

Look at the following structure declaration. ​struct Employee ​{ ​ string name; ​ int idNum; ​}; In this declaration, idNum is: A) a member B) an array C) a tag D) None of these

A. A member

3) Data types that are created by the programmer are known as ________. A) variables B) abstract data types (ADT) C) functions D) parameters E) None of these

Answer B abstract dat types (ADt)

A structure ________ contain members of the same data type. A) cannot B) can C) shouldn't D) None of these

Answer B can

If an anonymous union is declared globally (outside all functions), it must be ________. A) empty B) declared static C) explicitly declared "global" D) initialized and used outside any function E) None of these

Answer B declared static

) This allows you to access structure members. A) structure access operator B) dot operator C) #include <structaccess> directive D) getmember function E) None of these

Answer B dot operator

A declaration for an enumerated type begins with the ________ key word. A) enumerated B) enum_type C) enum D) ENUM

Answer C) enum

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)Strongly typed enum

) The name of the structure is referred to as its ________. A) data type B) argument C) parameter D) tag E) None of these

Answer E nine of these

If Circle is a structure, the statement: ​Circle *pcirc = nullptr; A) declares an empty structure variable called *pcirc B) declares a structure pointer called pcirc initialized with a null pointer C) is illegal in C++ D) initializes a null pointer with the value of the Circle pointer E) None of these

B. Declares a structure pointer called pcirc initialized with a null pointer

Look at the following declaration. ​enum Tree { OAK, MAPLE, PINE }; In memory, what value will the MAPLE enumerator be stored as? A) "MAPLE" B) 2 C) 'M' D) 1 E) 1.0

D. ) 1

14) Before a structure can be used, it must be ________. A) declared B) dereferenced C) initialized D) All of these E) None of these

Declared (A)

21) Look at the following structure declaration. ​struct Circle ​{ ​ double centerX; ​ double centerY; ​ double radius; ​}; Assume that circle1 and circle2 are variables of the Circle type, and their members have been initialized. True/False: The following if statement correctly determines whether the two variables' members contain the same data: ​if (circle1 == circle2)

False

10) False: 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:

False

15) True/False: A union can only have one member. Answer:

False

16) True/False: The names of the enumerators in an enumerated data type must be enclosed in quotation marks. Answer:

False

18) True/False: You cannot directly assign an enumerator to an int variable. Answer:

False

6) True/False: A function cannot modify the members of a structure. Answer:

False

Look at the following declaration. ​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.

False

The following union declaration appears on a system uses 4-byte ints and 8-byte doubles. ​union Numbers ​{ ​ int integerNumber; ​ double doubleNumber; ​}; ​Numbers myNumber; ​myNumber.integerNumber = 1; True/False: After this code executes, the myNumber variable will occupy 4 bytes of memory.

False

With an enumerated data type, the enumerators are stored in memory as ________. A) strings B) integers C) characters D) doubles

Integers answer B

17) A function ________ return a structure. A) may B) may not C) will always D) cannot possibly E) None of these

May

18) 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

The address of a variable structure

To dereference a structure pointer, the appropriate operator is ________. A) the ampersand, & B) an asterisk, * C) the structure pointer operator, -> D) the dereference operator, <- E) None of these

The structure pointer operator, -> Answer C

1) True/False: A struct can contain members with varying data types.

True

11) True/False: It is possible for a structure variable to be a member of another structure variable. Answer:

True

12) True/False: 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: TRUE

True

13) True/False: It is possible for a structure to contain as a member a pointer to its own structure type. Answer: TRUE

True

14) True/False: An anonymous union declaration actually creates the member variables in memory. Answer: TRUE

True

17) True/False: You cannot directly assign an integer value to an enum variable. Answer:

True

19) True/False: 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:

True

2) True/False: Any mathematical operations that can be performed on regular C++ variables can be performed on structure members.

True

20) True/False: In C++ 11, if you want to retrieve a strongly typed enumerator's underlying integer value, you must use a cast operator. Answer:

True

3) True/False: Structure variables may be passed as arguments to functions.

True

4) True/False: The structure pointer operator is used to dereference a pointer to a structure, not a pointer that is a member of a structure. Answer:

True

5) True/False: The expression s->m; indicates that s is a structure pointer and m is a structure member.

True

8) True/False: You can define any number of union variables, but each variable can only store the value of one member at a time. Answer:

True

True/False: If a function is legally prototyped to return an integer value, it can return a structure member that is an integer data type. Answer:

True

True/False: 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:

True

ich 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

cout<< student[1].gpa; Answer C

A good reason to pass a structure as a constant reference is ________. B) to ensure changes to the structure members C) to slow down the function's execution, preventing errors D) to speed up the function's modification of the structure members E) None of these

to prevent changes to the structure members answer A


Set pelajaran terkait

Lilley: Chapter 27 Antilipemic Drugs

View Set

25b IT Specialist Study Guide Chapter 6 Applied Network

View Set

Ch. 17: Creating an Implementation Plan and Sustaining Behaviors

View Set

Statistics 1.3 Simple Random Sampling/ 1.4 Other Effective Sampling Methods

View Set