Deck 8: Class Features and Design Issues
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Match between columns
Question
Question
Match between columns
Question
Question
Match between columns
Question
Match between columns
Question
Match between columns
Question
Match between columns
Question
Match between columns
Question
Match between columns
Question
Match between columns
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/53
Play
Full screen (f)
Deck 8: Class Features and Design Issues
1
____ functions perform some action or service, such as sorting data or searching for data.
A) Inspector
B) Predicate
C) Mutator
D) Auxiliary
A) Inspector
B) Predicate
C) Mutator
D) Auxiliary
D
2
____ functions return information about an object's state, or display some or all of an object's attributes.
A) Inspector
B) Manager
C) Mutator
D) Auxiliary
A) Inspector
B) Manager
C) Mutator
D) Auxiliary
A
3
The one's complement operator (____) is the operator that makes every bit become its opposite.
A) !
B) ^
C) ~
D) %
A) !
B) ^
C) ~
D) %
C
4
isUpper() is a typical example of a(n) ____ function.
A) manager
B) auxiliary
C) inspector
D) predicate
A) manager
B) auxiliary
C) inspector
D) predicate
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
5
getName() is a typical example of a(n) ____ function.
A) manager
B) auxiliary
C) inspector
D) predicate
A) manager
B) auxiliary
C) inspector
D) predicate
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
6
____ functions change an object's state or attributes.
A) Inspector
B) Manager
C) Mutator
D) Auxiliary
A) Inspector
B) Manager
C) Mutator
D) Auxiliary
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
7
A ____ is a collection of useful classes.
A) library
B) superclass
C) class hierarchy
D) module
A) library
B) superclass
C) class hierarchy
D) module
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
8
A ____ function has the same name as its class, preceded with a tilde.
A) constructor
B) manager
C) predicate
D) destructor
A) constructor
B) manager
C) predicate
D) destructor
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
9
An initialization list is the part of the constructor header to the left of the colon.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
10
The one's complement operator is also called the bitwise complement operator.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
11
A ____ constructor makes a local copy.
A) default
B) non-default
C) copy
D) bitwise
A) default
B) non-default
C) copy
D) bitwise
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
12
The composition relationship is called an "is-a" relationship.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
13
A ____ function has the same name as its class.
A) constructor
B) manager
C) predicate
D) mutator
A) constructor
B) manager
C) predicate
D) mutator
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
14
A(n) ____ is an internal name for the group of statements that make up the definition of a class.
A) #ifndef name
B) #define name
C) #ifdef name
D) #include name
A) #ifndef name
B) #define name
C) #ifdef name
D) #include name
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
15
Several destructors can exist for each class.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
16
sortAscending() is a typical example of a(n) ____ function.
A) manager
B) auxiliary
C) inspector
D) predicate
A) manager
B) auxiliary
C) inspector
D) predicate
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
17
Coupling is either tight coupling or loose coupling, depending on how much one function depends on information from another.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
18
____ functions create and destroy objects for you.
A) Constructor
B) Manager
C) Mutator
D) Auxiliary
A) Constructor
B) Manager
C) Mutator
D) Auxiliary
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
19
All constructors are public.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
20
____ functions test the truth of some condition.
A) Inspector
B) Predicate
C) Mutator
D) Auxiliary
A) Inspector
B) Predicate
C) Mutator
D) Auxiliary
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
21
If you want to create an array of class objects such as House aHouse[3] , the class must have a default ____________________.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
22
What does it mean to overload a constructor?
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
23
A(n) ____________________ constructor is one that does not require any arguments.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
24
How do constructor functions differ from other member functions?
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
25
____ refers to how well the operations in a function relate to one another.
A) Encapsulation
B) Abstraction
C) Cohesion
D) Coupling
A) Encapsulation
B) Abstraction
C) Cohesion
D) Coupling
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
26
The ____ directive means that you have reached the end of the block of code that you are defining.
A) #define
B) #endif
C) #ifdef
D) #ifndef
A) #define
B) #endif
C) #ifdef
D) #ifndef
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
27
The C++ directive ____ allows you to test whether a class has already been defined in a project; it means "if not defined."
A) #define
B) #endif
C) #ifdef
D) #ifndef
A) #define
B) #endif
C) #ifdef
D) #ifndef
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
28
____ cohesion occurs when all of the function operations contribute to the performance of only one task.
A) Functional
B) Procedural
C) Complete
D) Default
A) Functional
B) Procedural
C) Complete
D) Default
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
29
Using an object within another object is known as ____________________.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
30
____ are simple routines that do nothing (or very little).
A) Prototypes
B) Initialization lists
C) Stubs
D) Auxiliary functions
A) Prototypes
B) Initialization lists
C) Stubs
D) Auxiliary functions
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
31
Implement a default constructor for the following class:
class Employee
{
private:
int idNum;
double hourlyRate;
public:
Employee();
void setIdNum(const int);
void setHourlyRate(const double);
int getIdNum();
double getHourlyRate();
};
class Employee
{
private:
int idNum;
double hourlyRate;
public:
Employee();
void setIdNum(const int);
void setHourlyRate(const double);
int getIdNum();
double getHourlyRate();
};
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
32
What are the four special member functions that every C++ class object automatically has?
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
33
Why is it a good idea to implement your own default constructor, rather than letting C++ provide one?
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
34
What does the default destructor of a class do?
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
35
____ is a measure of the strength of the connection between two functions; it expresses the extent to which information is exchanged by functions.
A) Encapsulation
B) Abstraction
C) Cohesion
D) Coupling
A) Encapsulation
B) Abstraction
C) Cohesion
D) Coupling
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
36
The following code shows an example of ____:
Double square(double number)
{
Return (number * number);
}
A) coupling
B) tight coupling
C) loose coupling
D) functional cohesion
Double square(double number)
{
Return (number * number);
}
A) coupling
B) tight coupling
C) loose coupling
D) functional cohesion
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
37
Why must a constructor have the same name as its class?
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
38
In highly ____________________ functions, all operations are related.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
39
A(n) ____________________ list provides constructor-required values for the member-objects.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
40
A(n) ____________________ constructor is one that requires at least one argument.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
41
Match between columns
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
42
In the software industry, what is RAD?
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
43
Match between columns
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
44
Why should you avoid using digits in a variable, function or class name?
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
45
Match between columns
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
46
Match between columns
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
47
Match between columns
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
48
Match between columns
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
49
Match between columns
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
50
Match between columns
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
51
Match between columns
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
52
What is the difference between tight coupling and loose coupling in functions?
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
53
Modify the following class definition so that it uses the #ifndef , #define and #endif directives:
class Salesperson
{
private:
int idNum;
string name;
public:
Salesperson(int, string);
void display();
};
Salesperson::Salesperson(int id, string lastName)
{
idNum = id;
name = lastName;
}
void Salesperson::display()
{
cout
class Salesperson
{
private:
int idNum;
string name;
public:
Salesperson(int, string);
void display();
};
Salesperson::Salesperson(int id, string lastName)
{
idNum = id;
name = lastName;
}
void Salesperson::display()
{
cout
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck