Deck 7: Using Classes
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
Match between columns
سؤال
Match between columns
سؤال
Match between columns
سؤال
Match between columns
سؤال
Match between columns
سؤال
سؤال
Match between columns
سؤال
Match between columns
سؤال
سؤال
Match between columns
سؤال
سؤال
Match between columns
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/56
العب
ملء الشاشة (f)
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
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
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
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
A) instantiate
B) encapsulate
C) abstract
D) overload
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
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
A) public
B) private
C) protected
D) static
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
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
A) address
B) dot
C) scope resolution
D) pointer-to-member
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
7
The scope resolution operator is ____.
A) &
B) ::
C) *
D) ->
A) &
B) ::
C) *
D) ->
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
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();
A) aSophmore.displayStudentData();
B) Student.displayStudentData();
C) aSophmore::displayStudentData();
D) *aSophmore.displayStudentData();
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
9
C++ is an extensible language.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
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
A) header
B) definition
C) declaration
D) implementation
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
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
A) variable
B) field
C) structure
D) object
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
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
A) low-level
B) high-level
C) extensible
D) object-oriented
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
14
All members of a class share a single storage location for a static data member of that same class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
15
When you create a class, you usually make data items public.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
16
The value of a static field cannot be changed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
17
When you create a class, you usually make the functions private.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
18
To ____ components is to contain them.
A) instantiate
B) abstract
C) declare
D) encapsulate
A) instantiate
B) abstract
C) declare
D) encapsulate
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
19
An abstract data type is a type defined by C++.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
20
A class is a new data type you create that is more complex than the basic data types.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
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.
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
22
Why should you make class data fields private and not public?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
23
A function that is a user of your class is a class ____________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
24
The ______________________________ is constructed by using a dash followed by a right-angle bracket (or greater-than sign).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
25
When may it be a good idea to make data public in a class?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
26
____ variables are sometimes called class variables, class fields, or class-wide fields.
A) Public
B) Private
C) Constant
D) Static
A) Public
B) Private
C) Constant
D) Static
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
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
A) const
B) static
C) public
D) private
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
28
Static functions ____ access non-static variables.
A) can
B) cannot
C) should
D) should not
A) can
B) cannot
C) should
D) should not
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
29
Write a class with three private fields and then modify it so that the fields are public. Show both versions.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
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
A) *this.employeeIdNum
B) (*this).employeeIdNum
C) *(this.employeeIdNum)
D) *(this).employeeIdNum
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
31
Conventionally, object names begin with a(n) ____________________ letter.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
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
A) scope resolution
B) conditional
C) dot
D) address
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
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
A) static
B) const
C) public
D) private
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
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
A) this
B) super
C) const
D) void
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
35
Conventionally, class names begin with a(n) ____________________ letter.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
36
ADT stands for ____________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
37
____________________ variables belong to the class, and you can use them even if you never instantiate an object.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
38
When you create an object, a block of ____________________ is set aside for the data members.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
39
The ____ operator is the pointer-to-member operator.
A) ::
B) &
C) *
D) ->
A) ::
B) &
C) *
D) ->
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
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
A) public
B) private
C) static
D) const
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
41
Can you modify the this pointer? Why or why not?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
42
What is the difference in memory allocation between a static and a non-static variable?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
44
In what situation would you want to use the this pointer?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
45
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
46
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
47
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
48
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
49
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
50
Should static fields always be constant? Explain your answer.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
51
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
52
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
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?
void Customer::setBalance(double balance)
{
Customer::balance = balance;
}
Why is the scope resolution operator needed within the function body?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
54
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
55
Should you use a static class member with an object name or with the class name?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
56
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck