Deck 7: Using Classes

Full screen (f)
exit full mode
Question
When a class field is ____, only one memory location is allocated, no matter how many objects of the class you instantiate.

A) const
B) static
C) void
D) private
Use Space or
up arrow
down arrow
to flip the card.
Question
Programmers sometimes refer to ____ as an example of using a "black box."

A) polymorphism
B) encapsulation
C) instantiation
D) abstraction
Question
You ____ assign a value to a field in a class definition.

A) can
B) cannot
C) should
D) should not
Question
To ____ an object is to declare or create it.

A) instantiate
B) encapsulate
C) abstract
D) overload
Question
The access modifier ____ means a class member cannot be accessed using any statements in any functions that are not also part of the class.

A) public
B) private
C) protected
D) static
Question
You must use both the class name and the ____ operator when you implement a member function, because they tie the function to the class and allow every instantiated object to use the function name.

A) address
B) dot
C) scope resolution
D) pointer-to-member
Question
The scope resolution operator is ____.

A) &
B) ::
C) *
D) ->
Question
To use the function displayStudentData() of the object aSophmore that belongs to the class Student , the correct syntax is ____.

A) aSophmore.displayStudentData();
B) Student.displayStudentData();
C) aSophmore::displayStudentData();
D) *aSophmore.displayStudentData();
Question
C++ is an extensible language.
Question
The ____ section of a class contains the class name, variables (attributes), and function prototypes.

A) header
B) definition
C) declaration
D) implementation
Question
A C++ ____ is an instantiation of a class that can contain both data members and methods.

A) variable
B) field
C) structure
D) object
Question
A(n) ____ language is one to which you can add your own data types.

A) low-level
B) high-level
C) extensible
D) object-oriented
Question
You may use the this pointer instead of the class name and scope resolution operator when a local variable and a field name conflict.
Question
All members of a class share a single storage location for a static data member of that same class.
Question
When you create a class, you usually make data items public.
Question
The value of a static field cannot be changed.
Question
When you create a class, you usually make the functions private.
Question
To ____ components is to contain them.

A) instantiate
B) abstract
C) declare
D) encapsulate
Question
An abstract data type is a type defined by C++.
Question
A class is a new data type you create that is more complex than the basic data types.
Question
Consider the following class:
class Student
{
private:
int idNum;
string lastName;
double gradePointAverage;
};
Add a public function void displayStudentData() to the class definition and then write an implementation for the function.
Question
Why should you make class data fields private and not public?
Question
A function that is a user of your class is a class ____________________.
Question
The ______________________________ is constructed by using a dash followed by a right-angle bracket (or greater-than sign).
Question
When may it be a good idea to make data public in a class?
Question
____ variables are sometimes called class variables, class fields, or class-wide fields.

A) Public
B) Private
C) Constant
D) Static
Question
The only type of class member function that does not have a this pointer is a ____ member function.

A) const
B) static
C) public
D) private
Question
Static functions ____ access non-static variables.

A) can
B) cannot
C) should
D) should not
Question
Write a class with three private fields and then modify it so that the fields are public. Show both versions.
Question
The variable ____ is an example of a correct use of the this pointer.

A) *this.employeeIdNum
B) (*this).employeeIdNum
C) *(this.employeeIdNum)
D) *(this).employeeIdNum
Question
Conventionally, object names begin with a(n) ____________________ letter.
Question
When you use an object, the ____ operator, and a non-static function of the object's class, you actually pass the specific object's address to the function as an unseen argument.

A) scope resolution
B) conditional
C) dot
D) address
Question
When you do not want to declare an object, you can still access a static , class-wide field by using a function that is ____.

A) static
B) const
C) public
D) private
Question
The ____ pointer is automatically supplied every time you call a non-static member function of a class.

A) this
B) super
C) const
D) void
Question
Conventionally, class names begin with a(n) ____________________ letter.
Question
ADT stands for ____________________.
Question
____________________ variables belong to the class, and you can use them even if you never instantiate an object.
Question
When you create an object, a block of ____________________ is set aside for the data members.
Question
The ____ operator is the pointer-to-member operator.

A) ::
B) &
C) *
D) ->
Question
A ____ class member exists, even when you have not instantiated any objects of the class.

A) public
B) private
C) static
D) const
Question
Can you modify the this pointer? Why or why not?
Question
What is the difference in memory allocation between a static and a non-static variable?
Question
Write a class declaration that has three private fields and three functions that can be used to assign values to each of the data fields of the class. Write the implementation of one of the functions.
Question
In what situation would you want to use the this pointer?
Question
Match between columns
allows the same operation to be carried out differently depending on the object
implementation section
allows the same operation to be carried out differently depending on the object
class variable
allows the same operation to be carried out differently depending on the object
abstract data type
allows the same operation to be carried out differently depending on the object
pointer-to-member operator
allows the same operation to be carried out differently depending on the object
class
allows the same operation to be carried out differently depending on the object
this pointer
allows the same operation to be carried out differently depending on the object
interface
allows the same operation to be carried out differently depending on the object
polymorphism
allows the same operation to be carried out differently depending on the object
access modifier
Question
Match between columns
looks like an arrow
implementation section
looks like an arrow
class variable
looks like an arrow
abstract data type
looks like an arrow
pointer-to-member operator
looks like an arrow
class
looks like an arrow
this pointer
looks like an arrow
interface
looks like an arrow
polymorphism
looks like an arrow
access modifier
Question
Match between columns
holds the memory address of the current object that is using a class function
implementation section
holds the memory address of the current object that is using a class function
class variable
holds the memory address of the current object that is using a class function
abstract data type
holds the memory address of the current object that is using a class function
pointer-to-member operator
holds the memory address of the current object that is using a class function
class
holds the memory address of the current object that is using a class function
this pointer
holds the memory address of the current object that is using a class function
interface
holds the memory address of the current object that is using a class function
polymorphism
holds the memory address of the current object that is using a class function
access modifier
Question
Match between columns
field that does not belong to a specific object
implementation section
field that does not belong to a specific object
class variable
field that does not belong to a specific object
abstract data type
field that does not belong to a specific object
pointer-to-member operator
field that does not belong to a specific object
class
field that does not belong to a specific object
this pointer
field that does not belong to a specific object
interface
field that does not belong to a specific object
polymorphism
field that does not belong to a specific object
access modifier
Question
Match between columns
contains the functions of a class
implementation section
contains the functions of a class
class variable
contains the functions of a class
abstract data type
contains the functions of a class
pointer-to-member operator
contains the functions of a class
class
contains the functions of a class
this pointer
contains the functions of a class
interface
contains the functions of a class
polymorphism
contains the functions of a class
access modifier
Question
Should static fields always be constant? Explain your answer.
Question
Match between columns
intercedes between you and the inner workings of an object
implementation section
intercedes between you and the inner workings of an object
class variable
intercedes between you and the inner workings of an object
abstract data type
intercedes between you and the inner workings of an object
pointer-to-member operator
intercedes between you and the inner workings of an object
class
intercedes between you and the inner workings of an object
this pointer
intercedes between you and the inner workings of an object
interface
intercedes between you and the inner workings of an object
polymorphism
intercedes between you and the inner workings of an object
access modifier
Question
Match between columns
assigns accessibility to the declared variables that follow it
implementation section
assigns accessibility to the declared variables that follow it
class variable
assigns accessibility to the declared variables that follow it
abstract data type
assigns accessibility to the declared variables that follow it
pointer-to-member operator
assigns accessibility to the declared variables that follow it
class
assigns accessibility to the declared variables that follow it
this pointer
assigns accessibility to the declared variables that follow it
interface
assigns accessibility to the declared variables that follow it
polymorphism
assigns accessibility to the declared variables that follow it
access modifier
Question
Consider the function shown below:
void Customer::setBalance(double balance)
{
Customer::balance = balance;
}
Why is the scope resolution operator needed within the function body?
Question
Match between columns
a type you define
implementation section
a type you define
class variable
a type you define
abstract data type
a type you define
pointer-to-member operator
a type you define
class
a type you define
this pointer
a type you define
interface
a type you define
polymorphism
a type you define
access modifier
Question
Should you use a static class member with an object name or with the class name?
Question
Match between columns
category of objects
implementation section
category of objects
class variable
category of objects
abstract data type
category of objects
pointer-to-member operator
category of objects
class
category of objects
this pointer
category of objects
interface
category of objects
polymorphism
category of objects
access modifier
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/56
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 7: Using Classes
1
When a class field is ____, only one memory location is allocated, no matter how many objects of the class you instantiate.

A) const
B) static
C) void
D) private
B
2
Programmers sometimes refer to ____ as an example of using a "black box."

A) polymorphism
B) encapsulation
C) instantiation
D) abstraction
B
3
You ____ assign a value to a field in a class definition.

A) can
B) cannot
C) should
D) should not
B
4
To ____ an object is to declare or create it.

A) instantiate
B) encapsulate
C) abstract
D) overload
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
5
The access modifier ____ means a class member cannot be accessed using any statements in any functions that are not also part of the class.

A) public
B) private
C) protected
D) static
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
6
You must use both the class name and the ____ operator when you implement a member function, because they tie the function to the class and allow every instantiated object to use the function name.

A) address
B) dot
C) scope resolution
D) pointer-to-member
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
7
The scope resolution operator is ____.

A) &
B) ::
C) *
D) ->
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
8
To use the function displayStudentData() of the object aSophmore that belongs to the class Student , the correct syntax is ____.

A) aSophmore.displayStudentData();
B) Student.displayStudentData();
C) aSophmore::displayStudentData();
D) *aSophmore.displayStudentData();
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
9
C++ is an extensible language.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
10
The ____ section of a class contains the class name, variables (attributes), and function prototypes.

A) header
B) definition
C) declaration
D) implementation
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
11
A C++ ____ is an instantiation of a class that can contain both data members and methods.

A) variable
B) field
C) structure
D) object
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
12
A(n) ____ language is one to which you can add your own data types.

A) low-level
B) high-level
C) extensible
D) object-oriented
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
13
You may use the this pointer instead of the class name and scope resolution operator when a local variable and a field name conflict.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
14
All members of a class share a single storage location for a static data member of that same class.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
15
When you create a class, you usually make data items public.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
16
The value of a static field cannot be changed.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
17
When you create a class, you usually make the functions private.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
18
To ____ components is to contain them.

A) instantiate
B) abstract
C) declare
D) encapsulate
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
19
An abstract data type is a type defined by C++.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
20
A class is a new data type you create that is more complex than the basic data types.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
21
Consider the following class:
class Student
{
private:
int idNum;
string lastName;
double gradePointAverage;
};
Add a public function void displayStudentData() to the class definition and then write an implementation for the function.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
22
Why should you make class data fields private and not public?
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
23
A function that is a user of your class is a class ____________________.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
24
The ______________________________ is constructed by using a dash followed by a right-angle bracket (or greater-than sign).
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
25
When may it be a good idea to make data public in a class?
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
26
____ variables are sometimes called class variables, class fields, or class-wide fields.

A) Public
B) Private
C) Constant
D) Static
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
27
The only type of class member function that does not have a this pointer is a ____ member function.

A) const
B) static
C) public
D) private
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
28
Static functions ____ access non-static variables.

A) can
B) cannot
C) should
D) should not
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
29
Write a class with three private fields and then modify it so that the fields are public. Show both versions.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
30
The variable ____ is an example of a correct use of the this pointer.

A) *this.employeeIdNum
B) (*this).employeeIdNum
C) *(this.employeeIdNum)
D) *(this).employeeIdNum
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
31
Conventionally, object names begin with a(n) ____________________ letter.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
32
When you use an object, the ____ operator, and a non-static function of the object's class, you actually pass the specific object's address to the function as an unseen argument.

A) scope resolution
B) conditional
C) dot
D) address
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
33
When you do not want to declare an object, you can still access a static , class-wide field by using a function that is ____.

A) static
B) const
C) public
D) private
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
34
The ____ pointer is automatically supplied every time you call a non-static member function of a class.

A) this
B) super
C) const
D) void
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
35
Conventionally, class names begin with a(n) ____________________ letter.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
36
ADT stands for ____________________.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
37
____________________ variables belong to the class, and you can use them even if you never instantiate an object.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
38
When you create an object, a block of ____________________ is set aside for the data members.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
39
The ____ operator is the pointer-to-member operator.

A) ::
B) &
C) *
D) ->
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
40
A ____ class member exists, even when you have not instantiated any objects of the class.

A) public
B) private
C) static
D) const
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
41
Can you modify the this pointer? Why or why not?
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
42
What is the difference in memory allocation between a static and a non-static variable?
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
43
Write a class declaration that has three private fields and three functions that can be used to assign values to each of the data fields of the class. Write the implementation of one of the functions.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
44
In what situation would you want to use the this pointer?
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
45
Match between columns
allows the same operation to be carried out differently depending on the object
implementation section
allows the same operation to be carried out differently depending on the object
class variable
allows the same operation to be carried out differently depending on the object
abstract data type
allows the same operation to be carried out differently depending on the object
pointer-to-member operator
allows the same operation to be carried out differently depending on the object
class
allows the same operation to be carried out differently depending on the object
this pointer
allows the same operation to be carried out differently depending on the object
interface
allows the same operation to be carried out differently depending on the object
polymorphism
allows the same operation to be carried out differently depending on the object
access modifier
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
46
Match between columns
looks like an arrow
implementation section
looks like an arrow
class variable
looks like an arrow
abstract data type
looks like an arrow
pointer-to-member operator
looks like an arrow
class
looks like an arrow
this pointer
looks like an arrow
interface
looks like an arrow
polymorphism
looks like an arrow
access modifier
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
47
Match between columns
holds the memory address of the current object that is using a class function
implementation section
holds the memory address of the current object that is using a class function
class variable
holds the memory address of the current object that is using a class function
abstract data type
holds the memory address of the current object that is using a class function
pointer-to-member operator
holds the memory address of the current object that is using a class function
class
holds the memory address of the current object that is using a class function
this pointer
holds the memory address of the current object that is using a class function
interface
holds the memory address of the current object that is using a class function
polymorphism
holds the memory address of the current object that is using a class function
access modifier
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
48
Match between columns
field that does not belong to a specific object
implementation section
field that does not belong to a specific object
class variable
field that does not belong to a specific object
abstract data type
field that does not belong to a specific object
pointer-to-member operator
field that does not belong to a specific object
class
field that does not belong to a specific object
this pointer
field that does not belong to a specific object
interface
field that does not belong to a specific object
polymorphism
field that does not belong to a specific object
access modifier
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
49
Match between columns
contains the functions of a class
implementation section
contains the functions of a class
class variable
contains the functions of a class
abstract data type
contains the functions of a class
pointer-to-member operator
contains the functions of a class
class
contains the functions of a class
this pointer
contains the functions of a class
interface
contains the functions of a class
polymorphism
contains the functions of a class
access modifier
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
50
Should static fields always be constant? Explain your answer.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
51
Match between columns
intercedes between you and the inner workings of an object
implementation section
intercedes between you and the inner workings of an object
class variable
intercedes between you and the inner workings of an object
abstract data type
intercedes between you and the inner workings of an object
pointer-to-member operator
intercedes between you and the inner workings of an object
class
intercedes between you and the inner workings of an object
this pointer
intercedes between you and the inner workings of an object
interface
intercedes between you and the inner workings of an object
polymorphism
intercedes between you and the inner workings of an object
access modifier
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
52
Match between columns
assigns accessibility to the declared variables that follow it
implementation section
assigns accessibility to the declared variables that follow it
class variable
assigns accessibility to the declared variables that follow it
abstract data type
assigns accessibility to the declared variables that follow it
pointer-to-member operator
assigns accessibility to the declared variables that follow it
class
assigns accessibility to the declared variables that follow it
this pointer
assigns accessibility to the declared variables that follow it
interface
assigns accessibility to the declared variables that follow it
polymorphism
assigns accessibility to the declared variables that follow it
access modifier
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
53
Consider the function shown below:
void Customer::setBalance(double balance)
{
Customer::balance = balance;
}
Why is the scope resolution operator needed within the function body?
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
54
Match between columns
a type you define
implementation section
a type you define
class variable
a type you define
abstract data type
a type you define
pointer-to-member operator
a type you define
class
a type you define
this pointer
a type you define
interface
a type you define
polymorphism
a type you define
access modifier
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
55
Should you use a static class member with an object name or with the class name?
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
56
Match between columns
category of objects
implementation section
category of objects
class variable
category of objects
abstract data type
category of objects
pointer-to-member operator
category of objects
class
category of objects
this pointer
category of objects
interface
category of objects
polymorphism
category of objects
access modifier
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 56 flashcards in this deck.