C++ Chapter 11 Structured Data

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

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

a member

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

a tag

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

cout << student[1].gpa;

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

employee[2].hourlyWage = 75.00;

A declaration for an enumerated type begins with the __________ key word. a. enumerated b. enum_type c. enum d. ENUM e. None of these

enum

A function cannot modify the members of a structure.

false

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.

false

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)

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.

false

The names of enumerators in an enumerated data type must be enclosed in quotation marks.

false

You cannot directly assign an enumerator to an int variable.

false

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

semicolon

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

1

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

abstract data types (ADTs)

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

abstraction

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

all of these

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

all of these

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

by reference

A structure __________ contain members of the same data type. a. cannot b. can c. shouldn't d. None of these

can

Before a structure can be used it must be a. declared b. dereferenced c. initialized d. All of these e. None of these

declared

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

guarantees not to result in changes to the structure's members

With an enumerated data type, the enumerators are stored in memory as a. strings b. integers c. characters d. doubles

integers

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

it declares a structure pointer called pcirc initialized with a null pointer

A function __________ return a structure. a. may b. may not c. will always d. can never e. None of these

may

The name of a structure is referred to as its a. data type b. argument c. parameter d. tag e. None of these

none of these

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

output the dereferenced value pointed to by p

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

strongly typed enum

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

takes a Circle structure as a parameter, does something, and returns a Circle structure

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

the -> operator

. 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 structure variable

Which of the following will allow you to access structure members? a. the structure access operator b. the dot operator c. the #include<structaccess> directive d. the getmember function e. None of these

the dot operator

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

to prevent changes to the structure's memebrs

. A struct can contain members with varying data types.

true

Any mathematical operation that can be performed on regular C++ variables can be performed on structure members.

true

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

true

In C++11 if you want to retrieve a strongly typed enumerator's underlying integer value, you must use a cast operator.

true

It is possible for a structure to contain, as a member, a pointer to its own structure type.

true

It is possible for a structure variable to be a member of another structure variable.

true

Structure variables may be passed as arguments to functions.

true

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.

true

The expression s->m; indicates that s is a structure pointer and m is a structure member.

true

The structure pointer operator is used to dereference a pointer to a structure, not a pointer that is a member of a structure.

true

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.

true

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.

true

You cannot directly assign an integer value to an enum variable.

true

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

will store the character 't' in the fourth element of the publisher member of bookList[2]


Set pelajaran terkait

Human Evolutionary Biology - Final Exam

View Set

251 Specialized Traffic Enforcement

View Set

Consumer behavior chp 15(exam 2)

View Set

RN Nutrition Online Practice 2019 A

View Set

FIN 323 Chapter 5 Homework Practice for Exam

View Set