Deck 7: Introduction to Classes and Objects

ملء الشاشة (f)
exit full mode
سؤال
Object-oriented programming is centered around objects that include both data and the functions that operate on them.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
When the body of a member function is defined inside a class declaration, it is called a(n) ________ function.

A) static
B) global
C) inline
D) conditional
E) constructor
سؤال
A destructor is a member function that

A) is used to remove old unneeded objects.
B) causes the program to end.
C) is automatically called when an object is destroyed.
D) can only be called by the main function of a program.
E) None of the above.
سؤال
If Circle is the name of a class, which of the following statements would create a Circle object named myCircle?

A) myCircle Circle;
B) myCircle Circle();
C) Circle myCircle;
D) Circle myCircle();
E) None of the above
سؤال
In OOP terminology, an object's member variables are often called its ________, and its member functions are sometimes referred to as its ________.

A) values, operators
B) data, activities
C) attributes, activities
D) attributes, methods
E) values, activities
سؤال
A(n) ________ member function may be called by a statement in a function that is outside of the class.

A) inline
B) public
C) private
D) declared
E) constructor
سؤال
If setRadius is a Circle class function and myCircle is a Circle object, which of the following statements would set myCircle's radius to 2.5?

A) setRadius(2.5);
B) myCircle.setRadius(2.5);
C) Circle.setRadius(2.5);
D) Circle(setRadius(2.5));
E) None of the above
سؤال
A C++ member function that uses, but does not change, the value of a member variable is called

A) an accessor.
B) a mutator.
C) a user.
D) a constant.
E) a constructor.
سؤال
A structure has member variables, like an object, but they are usually all public and accessed directly with the dot operator, instead of by calling member functions.
سؤال
A constructor that does not require that any arguments be passed to it is called a(n) ________ constructor.

A) empty
B) default
C) stand-alone
D) zero-element
E) useless
سؤال
A constructor may have a return type of

A) int
B) bool
C) void
D) any of the above.
E) none of the above.
سؤال
Which of the following statements about ADTs are True.

A) They specify the values the data type can hold.
B) They specify the operations the data type can perform.
C) They hide the details of how the data type is implemented.
D) They do all of the above.
E) They do A and B, but not C.
سؤال
A class declaration provides a pattern for creating objects, but doesn't make any objects.
سؤال
Which of the following statements correctly creates an enumerated data type and defines an object of that type.

A) enum Season = {"Spring", "Summer", "Fall", "Winter"} favoriteSeason;
B) enum Season = {Spring, Summer, Fall, Winter}, Season favoriteSeason;
C) enum Season {Spring, Summer, Fall, Winter}, enum favoriteSeason;
D) ENUM Season {Spring, Summer, Fall, Winter} favoriteSeason;
E) None of these
سؤال
ADT stands for Algorithmic Data Type.
سؤال
When three different objects of a class are created, they are said to be separate ________ of the class.

A) members
B) ADTs
C) instances
D) children
E) None of the above
سؤال
An object typically hides its data, but allows outside code to access it through its

A) private member functions.
B) public member functions.
C) public data members.
D) access specifiers.
E) None of the above
سؤال
A constructor is a public class function that is automatically invoked (i.e., called) whenever a class object is created.
سؤال
Accessors are sometimes called ________ functions and mutators are sometimes called ________ functions.

A) set, get
B) get, set
C) public, private
D) private, public
E) regular, inline
سؤال
A class must have exactly one constructor.
سؤال
A structure variable is similar to a class object in which of the following ways?

A) It has member data that is usually private and accessed through public member functions.
B) Its data can be initialized with a constructor.
C) It can be passed to a function or returned from a function.
D) All of the above.
E) B and C, but not A.
سؤال
The bundling of an object's data and functions together is called

A) OOP.
B) encapsulation.
C) data hiding.
D) structuring.
E) private access.
سؤال
A constructor must have the same name as the

A) first private data member.
B) first public data member.
C) class.
D) first object of the class.
E) function return type.
سؤال
In C++ and other object-oriented programming languages, ADTs are normally implemented as classes.
سؤال
A class declaration creates an object.
سؤال
When an object or structure variable is passed to a function as a constant reference

A) the function accesses the original object, rather than a copy of it.
B) the function cannot make any changes to the member variables.
C) it is more efficient than passing it by value.
D) all of the above are True.
E) A and B are True, but not C.
سؤال
When a member function is defined outside of the class declaration, the function name must be qualified with the class name, followed by

A) a semicolon(;).
B) the scope resolution operator (::).
C) the public access specifier.
D) the private access specifier.
E) a tilde (~).
سؤال
A C++ member function that sets or changes the value stored in a member variable is called

A) an accessor.
B) a mutator.
C) a user.
D) a get function.
E) an updater.
سؤال
A class may have ________ default constructor(s) and ________ destructor(s).

A) only one, only one
B) only one, more than one
C) more than one, only one
D) more than one, more than one
E) no, only one
سؤال
If setSide is a Square class function and box is a Square object, which of the following statements would set the length of box's side to 5?

A) setSide(5);
B) box.setSide(5);
C) Square.setSide(5);
D) Square.setSide = 5;
E) None of the above
سؤال
A class can have a member variable that is an instance of another class. This is called object nesting.
سؤال
A private member function may only be called from a function that is a member of the same class.
سؤال
An Abstract data type (AD
T) is a programmer-defined data type that specifies the values the type can hold, the operations that can be performed on them, and how the operations will be implemented.
سؤال
An object is a(n) ________ of a class.

A) example
B) copy
C) instance
D) attribute
E) member
سؤال
The name of a destructor must begin with

A) the name of the class.
B) a tilde (~).
C) a capital letter.
D) an underscore.
E) none of the above.
سؤال
What will the following code segment display?
Enum Season {Spring, Summer, Fall, Winter} favoriteSeason;
FavoriteSeason = Summer;
Cout << favoriteSeason;

A) 1
B) 2
C) Summer
D) "Summer"
E) None of these.
سؤال
The ________ is used to protect important data.

A) default constructor
B) class protection operator
C) protect() member function
D) public access specifier
E) private access specifier
سؤال
A constructor is a public class function that gets called whenever you want to re-initialize an object's member data.
سؤال
If Square is the name of a class, which of the following statements would create a Square object named box?

A) box Square();
B) box Square;
C) Square box();
D) Square box;
E) None of the above
سؤال
Public members of a class object can be accessed from outside the class by using the

A) dot operator.
B) get function.
C) extraction operator.
D) member access operator.
E) class name.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/40
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 7: Introduction to Classes and Objects
1
Object-oriented programming is centered around objects that include both data and the functions that operate on them.
True
2
When the body of a member function is defined inside a class declaration, it is called a(n) ________ function.

A) static
B) global
C) inline
D) conditional
E) constructor
C
3
A destructor is a member function that

A) is used to remove old unneeded objects.
B) causes the program to end.
C) is automatically called when an object is destroyed.
D) can only be called by the main function of a program.
E) None of the above.
C
4
If Circle is the name of a class, which of the following statements would create a Circle object named myCircle?

A) myCircle Circle;
B) myCircle Circle();
C) Circle myCircle;
D) Circle myCircle();
E) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
5
In OOP terminology, an object's member variables are often called its ________, and its member functions are sometimes referred to as its ________.

A) values, operators
B) data, activities
C) attributes, activities
D) attributes, methods
E) values, activities
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
6
A(n) ________ member function may be called by a statement in a function that is outside of the class.

A) inline
B) public
C) private
D) declared
E) constructor
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
7
If setRadius is a Circle class function and myCircle is a Circle object, which of the following statements would set myCircle's radius to 2.5?

A) setRadius(2.5);
B) myCircle.setRadius(2.5);
C) Circle.setRadius(2.5);
D) Circle(setRadius(2.5));
E) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
8
A C++ member function that uses, but does not change, the value of a member variable is called

A) an accessor.
B) a mutator.
C) a user.
D) a constant.
E) a constructor.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
9
A structure has member variables, like an object, but they are usually all public and accessed directly with the dot operator, instead of by calling member functions.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
10
A constructor that does not require that any arguments be passed to it is called a(n) ________ constructor.

A) empty
B) default
C) stand-alone
D) zero-element
E) useless
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
11
A constructor may have a return type of

A) int
B) bool
C) void
D) any of the above.
E) none of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
12
Which of the following statements about ADTs are True.

A) They specify the values the data type can hold.
B) They specify the operations the data type can perform.
C) They hide the details of how the data type is implemented.
D) They do all of the above.
E) They do A and B, but not C.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
13
A class declaration provides a pattern for creating objects, but doesn't make any objects.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
14
Which of the following statements correctly creates an enumerated data type and defines an object of that type.

A) enum Season = {"Spring", "Summer", "Fall", "Winter"} favoriteSeason;
B) enum Season = {Spring, Summer, Fall, Winter}, Season favoriteSeason;
C) enum Season {Spring, Summer, Fall, Winter}, enum favoriteSeason;
D) ENUM Season {Spring, Summer, Fall, Winter} favoriteSeason;
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
15
ADT stands for Algorithmic Data Type.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
16
When three different objects of a class are created, they are said to be separate ________ of the class.

A) members
B) ADTs
C) instances
D) children
E) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
17
An object typically hides its data, but allows outside code to access it through its

A) private member functions.
B) public member functions.
C) public data members.
D) access specifiers.
E) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
18
A constructor is a public class function that is automatically invoked (i.e., called) whenever a class object is created.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
19
Accessors are sometimes called ________ functions and mutators are sometimes called ________ functions.

A) set, get
B) get, set
C) public, private
D) private, public
E) regular, inline
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
20
A class must have exactly one constructor.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
21
A structure variable is similar to a class object in which of the following ways?

A) It has member data that is usually private and accessed through public member functions.
B) Its data can be initialized with a constructor.
C) It can be passed to a function or returned from a function.
D) All of the above.
E) B and C, but not A.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
22
The bundling of an object's data and functions together is called

A) OOP.
B) encapsulation.
C) data hiding.
D) structuring.
E) private access.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
23
A constructor must have the same name as the

A) first private data member.
B) first public data member.
C) class.
D) first object of the class.
E) function return type.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
24
In C++ and other object-oriented programming languages, ADTs are normally implemented as classes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
25
A class declaration creates an object.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
26
When an object or structure variable is passed to a function as a constant reference

A) the function accesses the original object, rather than a copy of it.
B) the function cannot make any changes to the member variables.
C) it is more efficient than passing it by value.
D) all of the above are True.
E) A and B are True, but not C.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
27
When a member function is defined outside of the class declaration, the function name must be qualified with the class name, followed by

A) a semicolon(;).
B) the scope resolution operator (::).
C) the public access specifier.
D) the private access specifier.
E) a tilde (~).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
28
A C++ member function that sets or changes the value stored in a member variable is called

A) an accessor.
B) a mutator.
C) a user.
D) a get function.
E) an updater.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
29
A class may have ________ default constructor(s) and ________ destructor(s).

A) only one, only one
B) only one, more than one
C) more than one, only one
D) more than one, more than one
E) no, only one
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
30
If setSide is a Square class function and box is a Square object, which of the following statements would set the length of box's side to 5?

A) setSide(5);
B) box.setSide(5);
C) Square.setSide(5);
D) Square.setSide = 5;
E) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
31
A class can have a member variable that is an instance of another class. This is called object nesting.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
32
A private member function may only be called from a function that is a member of the same class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
33
An Abstract data type (AD
T) is a programmer-defined data type that specifies the values the type can hold, the operations that can be performed on them, and how the operations will be implemented.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
34
An object is a(n) ________ of a class.

A) example
B) copy
C) instance
D) attribute
E) member
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
35
The name of a destructor must begin with

A) the name of the class.
B) a tilde (~).
C) a capital letter.
D) an underscore.
E) none of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
36
What will the following code segment display?
Enum Season {Spring, Summer, Fall, Winter} favoriteSeason;
FavoriteSeason = Summer;
Cout << favoriteSeason;

A) 1
B) 2
C) Summer
D) "Summer"
E) None of these.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
37
The ________ is used to protect important data.

A) default constructor
B) class protection operator
C) protect() member function
D) public access specifier
E) private access specifier
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
38
A constructor is a public class function that gets called whenever you want to re-initialize an object's member data.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
39
If Square is the name of a class, which of the following statements would create a Square object named box?

A) box Square();
B) box Square;
C) Square box();
D) Square box;
E) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
40
Public members of a class object can be accessed from outside the class by using the

A) dot operator.
B) get function.
C) extraction operator.
D) member access operator.
E) class name.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.