Deck 9: Using Classes and Objects

ملء الشاشة (f)
exit full mode
سؤال
What do accessors do within the C# language?

A) They define how an instantiation of a class behaves.
B) They control access to the various properties of a class.
C) They provide access to a field of a class.
D) They specify the statements that execute when a class's fields are accessed.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Predefined types such as int, double, and char are all examples of what component of the C# language?

A) reference types
B) value types
C) output types
D) pointer types
سؤال
You can overload an operator for a built-in data type.For example, you can change the meaning of + between two ints.
سؤال
Where are the data components of a class that differ for each object stored?

A) Inside of instance variables.
B) In variable unit states.
C) Inside constants
D) Inside parent object relationships.
سؤال
Only nonstatic methods receive a this reference.
سؤال
What reference is passed implicitly and invisibly to every instance method and property accessor?

A) static
B) object
C) use
D) this
سؤال
Besides being known as a class client, what is a class that instantiates objects of another prewritten class known as?

A) a class state
B) a class instantiation
C) a class user
D) a server class
سؤال
What is another name used for instance variables in order to help distinguish them from other variables you might use?

A) states
B) relationships
C) instantiations
D) fields
سؤال
What class access modifier should you utilize to limit access to the assembly (a group of code modules compiled together) to which the class belongs?

A) private
B) internal
C) protected
D) public
سؤال
What class access modifier means that access to the class is not limited?

A) protected
B) private
C) internal
D) public
سؤال
What happens if you do not explicitly include an access specifier?

A) Its access modifier will be public by default.
B) It will be assumed as an internal field.
C) Its access modifier will be private by default.
D) It will be set to protected.
سؤال
If you don't write a constructor for a class object, C# writes one for you.
سؤال
A GUI object, such as a Button, is represented as an object that cannot encapsulate any methods.
سؤال
What class access modifier is used to indicate that access is limited to another class to which the class belongs?

A) private
B) internal
C) protected
D) public
سؤال
A parameter that is undeclared and that gets its value automatically is considered to be what type of parameter?

A) implicit
B) explicit
C) instance
D) property
سؤال
What class access modifier can be used to indicate 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
سؤال
Using private fields within classes is an example of what feature found in all object-oriented languages?

A) information hiding
B) polymorphism
C) inheritance
D) overloading
سؤال
When you create an array of objects, the array holds the actual value of each of the objects.
سؤال
What kind of constructor takes no arguments whatsoever?

A) object constructor
B) default constructor
C) construct initializer
D) construct array
سؤال
What are the set of attributes of an object's instance variable known as?

A) The object's relationship.
B) The object's state.
C) The object's class instantiation.
D) The object's fields.
سؤال
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 statement regarding the use of destructors is accurate?

A) A destructor performs actions when a class is instantiated.
B) A destructor must be explicitly created.
C) To declare a destructor, you must use a dash - followed by the class name.
D) You cannot provide any arguments to a destructor.
سؤال
Classes that support simple data items each contain a method that provides the details of how items in the class compare to each other.What is the name of this method?

A) Equals()
B) Less()
C) IndexOf()
D) CompareTo()
سؤال
A member of a class that provides access to a field of a class is referred to as what?

A) implicit parameter
B) property
C) explicit parameter
D) reference type
سؤال
What consists 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) A C# multifile assembly.
B) A defined framework.
C) A properly implemented interface.
D) A class destructor.
سؤال
Creating an object requires two steps that are shown in the example below:
Employee myAssistant;
myAssistant = new Employee();
What do these statements accomplish?
سؤال
What contains the actions you require when an instance of a class is destroyed, such as when the instance goes out of scope?

A) class constructor
B) constructor initializer
C) destructor
D) parameterless constructor
سؤال
What interface in C# 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
سؤال
What kind of property is one in which the code within the accessors is created automatically?

A) auto-implemented property
B) polymorphic property
C) dynamic property
D) abstract property
سؤال
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.
سؤال
Even though you can't specify this modifier for a named constant within a class, what is the effective access modifier for the constant?

A) public
B) private
C) static
D) internal
سؤال
What happens when a method overrides another method?

A) It instantiates that method and takes over its properties.
B) It takes precedence over the original method, hiding it.
C) It overloads the original method, allowing for varying parameters.
D) It extends the original method, adding additional functionality.
سؤال
Explain what a destructor is and why it cannot be overloaded.
سؤال
As an alternative to repeating code in multiple constructors, what can be used to indicate 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
سؤال
Briefly explain how to create instance variables, and show how to define a private integer instance variable called idNumber within a class called Employee.
سؤال
What are the class access modifiers in C#?
سؤال
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;}
}
سؤال
Briefly describe what an object initializer does and give a specific example.When is the object initializer assignment made?
سؤال
What is the difference between overriding a method and overloading a method with respect to method signatures?
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/39
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 9: Using Classes and Objects
1
What do accessors do within the C# language?

A) They define how an instantiation of a class behaves.
B) They control access to the various properties of a class.
C) They provide access to a field of a class.
D) They specify the statements that execute when a class's fields are accessed.
D
2
Predefined types such as int, double, and char are all examples of what component of the C# language?

A) reference types
B) value types
C) output types
D) pointer types
B
3
You can overload an operator for a built-in data type.For example, you can change the meaning of + between two ints.
False
4
Where are the data components of a class that differ for each object stored?

A) Inside of instance variables.
B) In variable unit states.
C) Inside constants
D) Inside parent object relationships.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
5
Only nonstatic methods receive a this reference.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
6
What reference is passed implicitly and invisibly to every instance method and property accessor?

A) static
B) object
C) use
D) this
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
7
Besides being known as a class client, what is a class that instantiates objects of another prewritten class known as?

A) a class state
B) a class instantiation
C) a class user
D) a server class
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
8
What is another name used for instance variables in order to help distinguish them from other variables you might use?

A) states
B) relationships
C) instantiations
D) fields
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
9
What class access modifier should you utilize to limit access to the assembly (a group of code modules compiled together) to which the class belongs?

A) private
B) internal
C) protected
D) public
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
10
What class access modifier means that access to the class is not limited?

A) protected
B) private
C) internal
D) public
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
11
What happens if you do not explicitly include an access specifier?

A) Its access modifier will be public by default.
B) It will be assumed as an internal field.
C) Its access modifier will be private by default.
D) It will be set to protected.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
12
If you don't write a constructor for a class object, C# writes one for you.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
13
A GUI object, such as a Button, is represented as an object that cannot encapsulate any methods.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
14
What class access modifier is used to indicate that access is limited to another class to which the class belongs?

A) private
B) internal
C) protected
D) public
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
15
A parameter that is undeclared and that gets its value automatically is considered to be what type of parameter?

A) implicit
B) explicit
C) instance
D) property
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
16
What class access modifier can be used to indicate 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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
17
Using private fields within classes is an example of what feature found in all object-oriented languages?

A) information hiding
B) polymorphism
C) inheritance
D) overloading
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
18
When you create an array of objects, the array holds the actual value of each of the objects.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
19
What kind of constructor takes no arguments whatsoever?

A) object constructor
B) default constructor
C) construct initializer
D) construct array
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
20
What are the set of attributes of an object's instance variable known as?

A) The object's relationship.
B) The object's state.
C) The object's class instantiation.
D) The object's fields.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
21
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;
}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
22
What statement regarding the use of destructors is accurate?

A) A destructor performs actions when a class is instantiated.
B) A destructor must be explicitly created.
C) To declare a destructor, you must use a dash - followed by the class name.
D) You cannot provide any arguments to a destructor.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
23
Classes that support simple data items each contain a method that provides the details of how items in the class compare to each other.What is the name of this method?

A) Equals()
B) Less()
C) IndexOf()
D) CompareTo()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
24
A member of a class that provides access to a field of a class is referred to as what?

A) implicit parameter
B) property
C) explicit parameter
D) reference type
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
25
What consists 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) A C# multifile assembly.
B) A defined framework.
C) A properly implemented interface.
D) A class destructor.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
26
Creating an object requires two steps that are shown in the example below:
Employee myAssistant;
myAssistant = new Employee();
What do these statements accomplish?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
27
What contains the actions you require when an instance of a class is destroyed, such as when the instance goes out of scope?

A) class constructor
B) constructor initializer
C) destructor
D) parameterless constructor
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
28
What interface in C# 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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
29
What kind of property is one in which the code within the accessors is created automatically?

A) auto-implemented property
B) polymorphic property
C) dynamic property
D) abstract property
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
30
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
31
Even though you can't specify this modifier for a named constant within a class, what is the effective access modifier for the constant?

A) public
B) private
C) static
D) internal
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
32
What happens when a method overrides another method?

A) It instantiates that method and takes over its properties.
B) It takes precedence over the original method, hiding it.
C) It overloads the original method, allowing for varying parameters.
D) It extends the original method, adding additional functionality.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
33
Explain what a destructor is and why it cannot be overloaded.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
34
As an alternative to repeating code in multiple constructors, what can be used to indicate 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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
35
Briefly explain how to create instance variables, and show how to define a private integer instance variable called idNumber within a class called Employee.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
36
What are the class access modifiers in C#?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
37
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;}
}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
38
Briefly describe what an object initializer does and give a specific example.When is the object initializer assignment made?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
39
What is the difference between overriding a method and overloading a method with respect to method signatures?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.