Deck 9: Using Classes and Objects

ملء الشاشة (f)
exit full mode
سؤال
The ____ class access modifier means that access is limited to another class to which the class belongs.

A) private
B) internal
C) protected
D) public
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Instance variables are often called ____ to help distinguish them from other variables you might use.

A) states
B) relationships
C) instantiations
D) fields
سؤال
The ____ class access modifier means that access is limited to the assembly (a group of code modules compiled together) to which the class belongs.

A) private
B) internal
C) protected
D) public
سؤال
When you create an array of objects, the array holds the actual value of each of the objects.
سؤال
The ____ class access modifier means that access to the class is not limited.

A) protected
B) private
C) internal
D) public
سؤال
The data components of a class that differ for each object are stored in ____.

A) instance variables
B) states
C) instantiations
D) relationships
سؤال
A(n) ____ parameter is one that is undeclared and that gets its value automatically.

A) implicit
B) explicit
C) instance
D) property
سؤال
If you do not provide an access specifier for a class field, its access is ____ by default.

A) public
B) internal
C) private
D) protected
سؤال
Properties have ____ that specify the statements that execute when a class's fields are accessed.

A) instance variables
B) fields
C) operators
D) accessors
سؤال
A class that instantiates objects of another prewritten class is known as a class client or class ____.

A) state
B) instantiation
C) user
D) server
سؤال
Using private fields within classes is an example of ____, a feature found in all object-oriented languages.

A) information hiding
B) polymorphism
C) inheritance
D) overloading
سؤال
Only nonstatic methods receive a this reference.
سؤال
Predefined types such as int , double , and char are ____ types.

A) reference
B) value
C) output
D) pointer
سؤال
A(n) ____ constructor will never take any parameters.

A) object
B) default
C) initializer
D) array
سؤال
The ____ class access modifier means that access to the class is limited to the class and to any classes derived from the class.

A) internal
B) private
C) protected
D) public
سؤال
The set of contents of an object's instance variables also is known as its ____.

A) relationship
B) state
C) instantiation
D) field
سؤال
An implicit, or invisible, ____ reference is passed to every instance method and property accessor.

A) static
B) object
C) use
D) this
سؤال
If you don't write a constructor for a class object, C# writes one for you.
سؤال
You can overload an operator for a built-in data type. For example, you can change the meaning of + between two int s.
سؤال
A GUI object, such as a Button , is represented as an object that cannot encapsulate any methods.
سؤال
What is the difference between overriding a method and overloading a method with respect to method signatures?
سؤال
The Sort() method accepts an array as a parameter and arranges its elements in descending order. What complication arises when you sort an array of objects? Explain how to use the IComparable interface to address this problem.
سؤال
As an alternative to repeating code in multiple constructors, a ____ indicates that another instance of a class constructor should be executed before any statements in the current constructor body.

A) parameterless constructor
B) value constructor
C) constructor initializer
D) default constructor
سؤال
When a method ____ another, it takes precedence over the method, hiding the original version.

A) instantiates
B) overrides
C) overloads
D) extends
سؤال
Briefly explain how to create instance variables, and show how to define a private integer instance variable called idNumber within a class called Employee .
سؤال
Classes that support simple data items each contain a method named ____, which provides the details of how items in the class compare to each other.

A) Equals()
B) Less()
C) IndexOf()
D) CompareTo()
سؤال
What are the three parts of a class definition in C#?
سؤال
Like any other C# method, constructors can be overloaded. Show how to create two public constructors-one with no parameters, and one with a parameter called sal -that both set the value for the property Salary within the following class:
class Employee
{
public double Salary;
}
سؤال
What are the class access modifiers in C#?
سؤال
A(n) ____ is a collection of abstract methods (and perhaps other members) that can be used by any class, as long as the class overrides the abstract method definitions.

A) multifile assembly
B) framework
C) interface
D) destructor
سؤال
Methods associated with objects are called ____________________.
سؤال
A ____ contains the actions you require when an instance of a class is destroyed-for example, when the instance goes out of scope.

A) constructor
B) constructor initializer
C) destructor
D) parameterless constructor
سؤال
Briefly describe what an object initializer does and give a specific example. When is the object initializer assignment made?
سؤال
A(n) ____________________ is a member of a class that provides access to a field of a class.
سؤال
Properties contain ____________________ for setting an object's fields.
سؤال
Creating an object requires two steps that are shown in the example below:
Employee myAssistant;
myAssistant = new Employee();
What do these statements accomplish?
سؤال
C# contains a(n) ____ interface, which contains the definition for the CompareTo() method that compares one object to another and returns an integer.

A) IComparable
B) Comparable
C) ICompareTo
D) CompareTo
سؤال
An object is a(n) ____________________ (tangible example) of a class.
سؤال
Write an example method that overrides the + operator to create a new book whose title is a concatenation of the titles of two books. For example, if the first book's title is "The Adventures of Tom Sawyer" and the second book's title is "The Adventures of Huckleberry Finn", the concatenated title will be "The Adventures of Tom Sawyer and The Adventures of Huckleberry Finn".  Assume the book class is defined as:
class Book
{
public Book( string title)
{
Title = title;
}
public string Title {get; set;}
}
سؤال
A(n) ____________________ is a method that instantiates (creates an instance of) an object.
سؤال
Match between columns
A definition containing an optional access modifier, the keyword class , and an identifier
reference type
A definition containing an optional access modifier, the keyword class , and an identifier
get accessor
A definition containing an optional access modifier, the keyword class , and an identifier
constructor initializer
A definition containing an optional access modifier, the keyword class , and an identifier
default constructor
A definition containing an optional access modifier, the keyword class , and an identifier
set accessor
A definition containing an optional access modifier, the keyword class , and an identifier
default value
A definition containing an optional access modifier, the keyword class , and an identifier
contextual keywords
A definition containing an optional access modifier, the keyword class , and an identifier
class client
A definition containing an optional access modifier, the keyword class , and an identifier
class header
The value of an object initialized with a default constructor
reference type
The value of an object initialized with a default constructor
get accessor
The value of an object initialized with a default constructor
constructor initializer
The value of an object initialized with a default constructor
default constructor
The value of an object initialized with a default constructor
set accessor
The value of an object initialized with a default constructor
default value
The value of an object initialized with a default constructor
contextual keywords
The value of an object initialized with a default constructor
class client
The value of an object initialized with a default constructor
class header
Sets an object's fields
reference type
Sets an object's fields
get accessor
Sets an object's fields
constructor initializer
Sets an object's fields
default constructor
Sets an object's fields
set accessor
Sets an object's fields
default value
Sets an object's fields
contextual keywords
Sets an object's fields
class client
Sets an object's fields
class header
Retrieves an object's field values
reference type
Retrieves an object's field values
get accessor
Retrieves an object's field values
constructor initializer
Retrieves an object's field values
default constructor
Retrieves an object's field values
set accessor
Retrieves an object's field values
default value
Retrieves an object's field values
contextual keywords
Retrieves an object's field values
class client
Retrieves an object's field values
class header
An automatically generated constructor for a class
reference type
An automatically generated constructor for a class
get accessor
An automatically generated constructor for a class
constructor initializer
An automatically generated constructor for a class
default constructor
An automatically generated constructor for a class
set accessor
An automatically generated constructor for a class
default value
An automatically generated constructor for a class
contextual keywords
An automatically generated constructor for a class
class client
An automatically generated constructor for a class
class header
Identifiers that act like keywords in specific circumstances
reference type
Identifiers that act like keywords in specific circumstances
get accessor
Identifiers that act like keywords in specific circumstances
constructor initializer
Identifiers that act like keywords in specific circumstances
default constructor
Identifiers that act like keywords in specific circumstances
set accessor
Identifiers that act like keywords in specific circumstances
default value
Identifiers that act like keywords in specific circumstances
contextual keywords
Identifiers that act like keywords in specific circumstances
class client
Identifiers that act like keywords in specific circumstances
class header
A type that refers to a specific memory location
reference type
A type that refers to a specific memory location
get accessor
A type that refers to a specific memory location
constructor initializer
A type that refers to a specific memory location
default constructor
A type that refers to a specific memory location
set accessor
A type that refers to a specific memory location
default value
A type that refers to a specific memory location
contextual keywords
A type that refers to a specific memory location
class client
A type that refers to a specific memory location
class header
A program or class that instantiates objects of another prewritten class
reference type
A program or class that instantiates objects of another prewritten class
get accessor
A program or class that instantiates objects of another prewritten class
constructor initializer
A program or class that instantiates objects of another prewritten class
default constructor
A program or class that instantiates objects of another prewritten class
set accessor
A program or class that instantiates objects of another prewritten class
default value
A program or class that instantiates objects of another prewritten class
contextual keywords
A program or class that instantiates objects of another prewritten class
class client
A program or class that instantiates objects of another prewritten class
class header
An alternative to repeating code in the constructors
reference type
An alternative to repeating code in the constructors
get accessor
An alternative to repeating code in the constructors
constructor initializer
An alternative to repeating code in the constructors
default constructor
An alternative to repeating code in the constructors
set accessor
An alternative to repeating code in the constructors
default value
An alternative to repeating code in the constructors
contextual keywords
An alternative to repeating code in the constructors
class client
An alternative to repeating code in the constructors
class header
سؤال
Explain what a destructor is and why it cannot be overloaded.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/42
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 9: Using Classes and Objects
1
The ____ class access modifier means that access is limited to another class to which the class belongs.

A) private
B) internal
C) protected
D) public
A
2
Instance variables are often called ____ to help distinguish them from other variables you might use.

A) states
B) relationships
C) instantiations
D) fields
D
3
The ____ class access modifier means that access is limited to the assembly (a group of code modules compiled together) to which the class belongs.

A) private
B) internal
C) protected
D) public
B
4
When you create an array of objects, the array holds the actual value of each of the objects.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
5
The ____ class access modifier means that access to the class is not limited.

A) protected
B) private
C) internal
D) public
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
6
The data components of a class that differ for each object are stored in ____.

A) instance variables
B) states
C) instantiations
D) relationships
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
7
A(n) ____ parameter is one that is undeclared and that gets its value automatically.

A) implicit
B) explicit
C) instance
D) property
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
8
If you do not provide an access specifier for a class field, its access is ____ by default.

A) public
B) internal
C) private
D) protected
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
9
Properties have ____ that specify the statements that execute when a class's fields are accessed.

A) instance variables
B) fields
C) operators
D) accessors
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
10
A class that instantiates objects of another prewritten class is known as a class client or class ____.

A) state
B) instantiation
C) user
D) server
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
11
Using private fields within classes is an example of ____, a feature found in all object-oriented languages.

A) information hiding
B) polymorphism
C) inheritance
D) overloading
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
12
Only nonstatic methods receive a this reference.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
13
Predefined types such as int , double , and char are ____ types.

A) reference
B) value
C) output
D) pointer
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
14
A(n) ____ constructor will never take any parameters.

A) object
B) default
C) initializer
D) array
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
15
The ____ class access modifier means that access to the class is limited to the class and to any classes derived from the class.

A) internal
B) private
C) protected
D) public
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
16
The set of contents of an object's instance variables also is known as its ____.

A) relationship
B) state
C) instantiation
D) field
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
17
An implicit, or invisible, ____ reference is passed to every instance method and property accessor.

A) static
B) object
C) use
D) this
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
18
If you don't write a constructor for a class object, C# writes one for you.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
19
You can overload an operator for a built-in data type. For example, you can change the meaning of + between two int s.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
20
A GUI object, such as a Button , is represented as an object that cannot encapsulate any methods.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
21
What is the difference between overriding a method and overloading a method with respect to method signatures?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
22
The Sort() method accepts an array as a parameter and arranges its elements in descending order. What complication arises when you sort an array of objects? Explain how to use the IComparable interface to address this problem.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
23
As an alternative to repeating code in multiple constructors, a ____ indicates that another instance of a class constructor should be executed before any statements in the current constructor body.

A) parameterless constructor
B) value constructor
C) constructor initializer
D) default constructor
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
24
When a method ____ another, it takes precedence over the method, hiding the original version.

A) instantiates
B) overrides
C) overloads
D) extends
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
25
Briefly explain how to create instance variables, and show how to define a private integer instance variable called idNumber within a class called Employee .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
26
Classes that support simple data items each contain a method named ____, which provides the details of how items in the class compare to each other.

A) Equals()
B) Less()
C) IndexOf()
D) CompareTo()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
27
What are the three parts of a class definition in C#?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
28
Like any other C# method, constructors can be overloaded. Show how to create two public constructors-one with no parameters, and one with a parameter called sal -that both set the value for the property Salary within the following class:
class Employee
{
public double Salary;
}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
29
What are the class access modifiers in C#?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
30
A(n) ____ is a collection of abstract methods (and perhaps other members) that can be used by any class, as long as the class overrides the abstract method definitions.

A) multifile assembly
B) framework
C) interface
D) destructor
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
31
Methods associated with objects are called ____________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
32
A ____ contains the actions you require when an instance of a class is destroyed-for example, when the instance goes out of scope.

A) constructor
B) constructor initializer
C) destructor
D) parameterless constructor
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
33
Briefly describe what an object initializer does and give a specific example. When is the object initializer assignment made?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
34
A(n) ____________________ is a member of a class that provides access to a field of a class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
35
Properties contain ____________________ for setting an object's fields.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
36
Creating an object requires two steps that are shown in the example below:
Employee myAssistant;
myAssistant = new Employee();
What do these statements accomplish?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
37
C# contains a(n) ____ interface, which contains the definition for the CompareTo() method that compares one object to another and returns an integer.

A) IComparable
B) Comparable
C) ICompareTo
D) CompareTo
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
38
An object is a(n) ____________________ (tangible example) of a class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
39
Write an example method that overrides the + operator to create a new book whose title is a concatenation of the titles of two books. For example, if the first book's title is "The Adventures of Tom Sawyer" and the second book's title is "The Adventures of Huckleberry Finn", the concatenated title will be "The Adventures of Tom Sawyer and The Adventures of Huckleberry Finn".  Assume the book class is defined as:
class Book
{
public Book( string title)
{
Title = title;
}
public string Title {get; set;}
}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
40
A(n) ____________________ is a method that instantiates (creates an instance of) an object.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
41
Match between columns
A definition containing an optional access modifier, the keyword class , and an identifier
reference type
A definition containing an optional access modifier, the keyword class , and an identifier
get accessor
A definition containing an optional access modifier, the keyword class , and an identifier
constructor initializer
A definition containing an optional access modifier, the keyword class , and an identifier
default constructor
A definition containing an optional access modifier, the keyword class , and an identifier
set accessor
A definition containing an optional access modifier, the keyword class , and an identifier
default value
A definition containing an optional access modifier, the keyword class , and an identifier
contextual keywords
A definition containing an optional access modifier, the keyword class , and an identifier
class client
A definition containing an optional access modifier, the keyword class , and an identifier
class header
The value of an object initialized with a default constructor
reference type
The value of an object initialized with a default constructor
get accessor
The value of an object initialized with a default constructor
constructor initializer
The value of an object initialized with a default constructor
default constructor
The value of an object initialized with a default constructor
set accessor
The value of an object initialized with a default constructor
default value
The value of an object initialized with a default constructor
contextual keywords
The value of an object initialized with a default constructor
class client
The value of an object initialized with a default constructor
class header
Sets an object's fields
reference type
Sets an object's fields
get accessor
Sets an object's fields
constructor initializer
Sets an object's fields
default constructor
Sets an object's fields
set accessor
Sets an object's fields
default value
Sets an object's fields
contextual keywords
Sets an object's fields
class client
Sets an object's fields
class header
Retrieves an object's field values
reference type
Retrieves an object's field values
get accessor
Retrieves an object's field values
constructor initializer
Retrieves an object's field values
default constructor
Retrieves an object's field values
set accessor
Retrieves an object's field values
default value
Retrieves an object's field values
contextual keywords
Retrieves an object's field values
class client
Retrieves an object's field values
class header
An automatically generated constructor for a class
reference type
An automatically generated constructor for a class
get accessor
An automatically generated constructor for a class
constructor initializer
An automatically generated constructor for a class
default constructor
An automatically generated constructor for a class
set accessor
An automatically generated constructor for a class
default value
An automatically generated constructor for a class
contextual keywords
An automatically generated constructor for a class
class client
An automatically generated constructor for a class
class header
Identifiers that act like keywords in specific circumstances
reference type
Identifiers that act like keywords in specific circumstances
get accessor
Identifiers that act like keywords in specific circumstances
constructor initializer
Identifiers that act like keywords in specific circumstances
default constructor
Identifiers that act like keywords in specific circumstances
set accessor
Identifiers that act like keywords in specific circumstances
default value
Identifiers that act like keywords in specific circumstances
contextual keywords
Identifiers that act like keywords in specific circumstances
class client
Identifiers that act like keywords in specific circumstances
class header
A type that refers to a specific memory location
reference type
A type that refers to a specific memory location
get accessor
A type that refers to a specific memory location
constructor initializer
A type that refers to a specific memory location
default constructor
A type that refers to a specific memory location
set accessor
A type that refers to a specific memory location
default value
A type that refers to a specific memory location
contextual keywords
A type that refers to a specific memory location
class client
A type that refers to a specific memory location
class header
A program or class that instantiates objects of another prewritten class
reference type
A program or class that instantiates objects of another prewritten class
get accessor
A program or class that instantiates objects of another prewritten class
constructor initializer
A program or class that instantiates objects of another prewritten class
default constructor
A program or class that instantiates objects of another prewritten class
set accessor
A program or class that instantiates objects of another prewritten class
default value
A program or class that instantiates objects of another prewritten class
contextual keywords
A program or class that instantiates objects of another prewritten class
class client
A program or class that instantiates objects of another prewritten class
class header
An alternative to repeating code in the constructors
reference type
An alternative to repeating code in the constructors
get accessor
An alternative to repeating code in the constructors
constructor initializer
An alternative to repeating code in the constructors
default constructor
An alternative to repeating code in the constructors
set accessor
An alternative to repeating code in the constructors
default value
An alternative to repeating code in the constructors
contextual keywords
An alternative to repeating code in the constructors
class client
An alternative to repeating code in the constructors
class header
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
42
Explain what a destructor is and why it cannot be overloaded.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.