Structures – Flashcards

Unlock all answers in this set

Unlock answers
question
1. This describes only the general characteristics of an object. a. initialization b. detailed specification c. initiation d. None of these
answer
b. detailed specification
question
2. 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. All of these
question
3. This is required after the closing brace of the structure declaration. a. square bracket b. period c. semicolon d. colon e. None of these
answer
c. semicolon
question
4. Look at the following statement. bookList[2].publisher[3] = 't'; This statement... a. is illegal in C++. b. will change the publisher's 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 ultimately result in a runtime error. e. None of these.
answer
c. will store the character 't' in the fourth element of the publisher member of booklist[2].
question
5. When a structure is passed _________to a function, its members are not copied. a. by reference b. by value c. Neither of these
answer
a. by reference
question
6. 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. All of these e. None of these
answer
b. guarantees not to result in changes to the structure's members.
question
7. This is like a structure, except all members occupy the same memory area. a. array b. union c. structure pointer d. array of pointers e. None of these
answer
b. union
question
8. Members of a(n) ________ union have names, but the union itself has no name. a. anonymous b. dereferenced c. organized d. declared e. None of these
answer
a. anonymous
question
9. If Circle is a structure tag, the statement Circle doSomething(Circle c2) can be the header line for a function that 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. takes a Circle structure as a parameter, does something, and returns a Circle structure
question
10. 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 = 100.00; e. None of these
answer
d. employee[2].hourlyWage = 100.00;
question
12. 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
question
13. 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 data types (ADT)
question
14. Before a structure can be used, it must be a. declared b. deallocated c. initialized d. All of these e. None of these
answer
a. declared
question
15. The name of the structure is referred to as its a. data type b. argument c. parameter d. tag e. None of these
answer
d. tag
question
16. This allows you to access structure members. a. structure access operator b. dot operator c. #include directive d. getmember function e. None of these
answer
b. dot operator
question
17. A function ___________ return a structure. a. may b. may not c. will always d. cannot possibly e. None of these
answer
a. may
question
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
answer
a. The address of a structure variable
question
19. 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
answer
c. the structure pointer operator, ->
question
20. 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. Output the dereferenced value pointed to by p
question
21. A structure _____________ contain members of the same data type. a. cannot b. can c. shouldn't d. None of these
answer
b. can
question
22. 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. cout << student[1].gpa;
question
23. If Circle is a structure tag, the statement Circle *pcirc; a. declares a structure variable called *pcirc b. declares a structure pointer called pcirc c. is illegal in C++ d. initializes a Circle pointer e. None of these
answer
b. declares a structure pointer called pcirc
question
24. A good reason to pass a structure as a constant reference is: a. to prevent changes to the structure members 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
answer
a. to prevent changes to the structure members
question
25. A declaration for an enumerated type begins with this key word. a. enumerated b. enum_type c. enum d. ENUM
answer
c. enum
question
26. With an enumerated data type, the enumerators are stored in memory as a. strings b. integers c. characters d. doubles
answer
b. integers
question
27. 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
answer
d. 1
question
28. 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.
answer
b. false
question
29. 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 tag
question
30. 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
answer
a. a member
Get an explanation on any task
Get unstuck with the help of our AI assistant in seconds
New