Deck 4: Creating Your Own Classes

Full screen (f)
exit full mode
Question
ToString( ),Equals( ),GetType( ),and GetHashCode( )are all methods of the object class.
Use Space or
up arrow
down arrow
to flip the card.
Question
A standard naming convention in C# for properties is to use the same name as the instance variable or field,except begin the identifier using an uppercase character.
Question
The keyword new is used as an operator to call constructor methods.
Question
A standard convention used by C# programmers is to use camel case style for property identifiers;Camel case style convention is also used for data member identifiers.
Question
A private access modifier is always associated with data members,methods,and constructors of a class.
Question
When you define a property,you can define the set without the get,but you must define a get.
Question
When you define methods of a class,you are defining its behaviors,in terms of what kinds of things it can do.
Question
If you overwrite the ToString( )method,you should also override the other methods of the object class.
Question
Three of the contextual keywords associated with properties are get,set,and value.
Question
A class is an instance of an object.
Question
The return type for constructors is always the type of the class.
Question
When you define a class method,you define its characteristics or fields in terms of the data.
Question
A property looks like a method because it directly represents a storage location.
Question
A constructor is used to instantiate a class from an object.
Question
Mutators are special types of methods used to create objects.
Question
With the object-oriented approach,objects send messages to other objects and receive messages from objects.
Question
The ToString( )method of the Console class should be overwritten.
Question
An object is like a class template.The object is used to define the structure for the different classes that are going to be of that type.
Question
A class named River will have a constructor named River.
Question
When you define a class and determine what data members it should have,you are declaring instance variables or fields that will represent the state of an object.
Question
Constructors differ from other methods in that constructors ____.

A) are not defined by the programmer
B) always return a value
C) are defined outside of the class
D) use the same identifier as the class
Question
Local variables ____.

A) are defined inside Main( ) and other methods
B) must be defined as private
C) are defined in classes
D) determine the data characteristics for the class
Question
A property resembles a(n)____,but is more closely aligned to a(n)____.

A) data field, method
B) method, data field
C) object, mutator
D) mutator, accessor
Question
A class is normally associated with a(n)____,which often describes a person,place,or thing and is normally a noun.

A) method member
B) behavior
C) data member
D) entity
Question
Use a type prefix,such as C for class name.For example,a student class should be named CStudent.
Question
Constructors are methods.
Question
All data types are initialized to 0 when an object is constructed.
Question
Accessors are special types of methods in C# used to instantiate an object of the class.
Question
Instance methods must have the static keyword in their heading.
Question
To add full functionality to your classes,____.

A) write more than one constructor
B) write a default constructor
C) write at least five constructors for each class
D) omit writing a constructor so that the default one will be created for you
Question
The ToString( )method is automatically invoked when the Write( )or WriteLine( )methods are called.
Question
The default constructor normally has an empty body.
Question
To program an object-oriented solution begin by determining what ____ are needed in the solution.

A) data
B) objects
C) processes
D) methods
Question
C# is an object-oriented language.All the code for an application must be placed in a(n)____.

A) file
B) object
C) class
D) method
Question
Design your classes to be as flexible and full-featured as possible.One way to do this is to include multiple instance data members.
Question
Accessors are also referred to as ____.

A) mutators
B) properties
C) getters
D) classes
Question
When you define the class,you describe its ____ in terms of data and its behaviors,or methods,in terms of what kinds of things it can do.

A) attributes
B) fields
C) characteristics
D) all of the above
Question
Since the data members of the class are defined as private,their public property counterpart must be used to assign new values to the data members.
Question
When you create an application that has two files,both must have a Main( )method.
Question
Constructors should be defined with a ____ access modifier.

A) public
B) private
C) protected
D) static
Question
The ToString( )method is automatically invoked when an object reference is made in the ____.

A) class constructor
B) Write( ) method
C) mutator method
D) object class
Question
Which of the following is NOT one of the inherited member methods of the object class?

A) ToString( )
B) Equals( )
C) GetType( )
D) Main( )
Question
Variables declared in the Main( )method are ____.

A) visible inside any method in the class.
B) are automatically initialized to zero.
C) must be defined as private data members.
D) only visible inside Main( ).
Question
Instance methods manipulate data by ____.

A) directly accessing private data members.
B) passing information as arguments through parameters.
C) using constructors and accessors.
D) sending visible data in the Main( ) method.
Question
Normally data members are defined to have ____ access.

A) public
B) private
C) protected
D) internal
Question
Constructors ____.

A) can be overloaded.
B) do not have to be written.
C) do not return a value.
D) all of the above.
Question
Accessors,mutators,and other instance methods are normally defined with what type of access modifier?

A) private
B) protected
C) internal
D) public
Question
Instance methods are ____.

A) nonstatic methods.
B) also called class methods.
C) defined in the Main( ) method.
D) defined outside of the class.
Question
____ are special methods used to read the current state or value of an object member's data.

A) Accessors
B) Mutators
C) Constructors
D) Setters
Question
What will be displayed from the above line?

A) Value = 12,346
B) Value = 12346
C) Value = 12,345
D) Value = 12,346.0
Question
When you define a class,you can use ____ to display all public members of the class (once an object is instantiated).

A) constructors
B) intellisense
C) instance methods
D) class diagrams
Question
If proper naming conventions were used in the above statement,which of the following statements is true?

A) PricePerSqYard is a property
B) plush is an object
C) 40.99 is a numeric literal
D) all of the above
Question
Class methods manipulate data by ____.

A) directly accessing private data members.
B) passing information as arguments through parameters.
C) using constructors and accessors.
D) sending visible data in the Main( ) method.
Question
Which of the following is true regarding methods of a class?

A) You must use the keyword static.
B) They are called instance methods.
C) To call methods of the class in the class, you must prefix the method name with the class name.
D) No return type is used when you define a class method.
Question
To design a class that is flexible and full-featured,____.

A) define a constructor for every possible combination of data members.
B) define a default constructor.
C) define at least three constructors.
D) include multiple constructors.
Question
In order to provide a new definition for the ToString( )method,____.

A) it must be defined using the new operator.
B) there must be at least one constructor defined.
C) use the keyword override in the heading
D) both mutators and accessors must have been defined.
Question
Which of the following is NOT a true statement relating to constructors?

A) To add full functionality to your classes, write multiple constructors
B) If you write one constructor, you lose the default one that is created automatically.
C) The default constructor must be the first one written for the class.
D) Constructors are used to provide values to the object's data members.
Question
The static keyword must not be used with ____.

A) data members
B) instance methods
C) class methods
D) all of the above
Question
To define a property to change a data member of a class include a ____ clause.

A) mutator
B) get
C) set
D) value
Question
In order to test a class,____.

A) a different class is needed.
B) invoke instance methods using the objects you construct.
C) use the properties to assign and retrieve values.
D) all of the above.
Question
After the class diagram is created,add the names of data members or fields and methods
using the_________________ section.
Question
After a project has been created and a new class added to your application,you can use the ____________ Window in Visual Studio to create a class diagram.
Question
The ____________ constructor does not have any parameters and normally has no body,just opening and closing curly braces.
Question
The body of the constructor methods consist primarily of ____________.
Question
Fields or data members are also called ____________.
Question
Accessor and mutators are ____________ methods
Question
As with overloaded methods,____________ must differ for constructors.
Question
By abstracting out the attributes (data)and the behaviors (processes on the data),you can create a(n)____________ to serve as a template from which many objects of that type can be instantiated.
Question
Data members should be defined with an access mode of ____________.
Question
C# is an object-oriented language as such all the code that you write has to be placed in a(n)____________.
Question
During the design phase,it is important to develop a(n)____________ illustrating what the desired final output should be.
Question
____________ access modifier is always associated with constructors.
Question
Constructors are used to ____________ a class.
Question
When you define the class,you describe its ____________,or characteristics or fields,in terms of data.
Question
If berber is an object,the statement Console.Write(berber);automatically invokes the ____________ method.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/75
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 4: Creating Your Own Classes
1
ToString( ),Equals( ),GetType( ),and GetHashCode( )are all methods of the object class.
True
2
A standard naming convention in C# for properties is to use the same name as the instance variable or field,except begin the identifier using an uppercase character.
True
3
The keyword new is used as an operator to call constructor methods.
True
4
A standard convention used by C# programmers is to use camel case style for property identifiers;Camel case style convention is also used for data member identifiers.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
5
A private access modifier is always associated with data members,methods,and constructors of a class.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
6
When you define a property,you can define the set without the get,but you must define a get.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
7
When you define methods of a class,you are defining its behaviors,in terms of what kinds of things it can do.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
8
If you overwrite the ToString( )method,you should also override the other methods of the object class.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
9
Three of the contextual keywords associated with properties are get,set,and value.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
10
A class is an instance of an object.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
11
The return type for constructors is always the type of the class.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
12
When you define a class method,you define its characteristics or fields in terms of the data.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
13
A property looks like a method because it directly represents a storage location.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
14
A constructor is used to instantiate a class from an object.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
15
Mutators are special types of methods used to create objects.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
16
With the object-oriented approach,objects send messages to other objects and receive messages from objects.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
17
The ToString( )method of the Console class should be overwritten.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
18
An object is like a class template.The object is used to define the structure for the different classes that are going to be of that type.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
19
A class named River will have a constructor named River.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
20
When you define a class and determine what data members it should have,you are declaring instance variables or fields that will represent the state of an object.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
21
Constructors differ from other methods in that constructors ____.

A) are not defined by the programmer
B) always return a value
C) are defined outside of the class
D) use the same identifier as the class
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
22
Local variables ____.

A) are defined inside Main( ) and other methods
B) must be defined as private
C) are defined in classes
D) determine the data characteristics for the class
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
23
A property resembles a(n)____,but is more closely aligned to a(n)____.

A) data field, method
B) method, data field
C) object, mutator
D) mutator, accessor
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
24
A class is normally associated with a(n)____,which often describes a person,place,or thing and is normally a noun.

A) method member
B) behavior
C) data member
D) entity
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
25
Use a type prefix,such as C for class name.For example,a student class should be named CStudent.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
26
Constructors are methods.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
27
All data types are initialized to 0 when an object is constructed.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
28
Accessors are special types of methods in C# used to instantiate an object of the class.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
29
Instance methods must have the static keyword in their heading.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
30
To add full functionality to your classes,____.

A) write more than one constructor
B) write a default constructor
C) write at least five constructors for each class
D) omit writing a constructor so that the default one will be created for you
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
31
The ToString( )method is automatically invoked when the Write( )or WriteLine( )methods are called.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
32
The default constructor normally has an empty body.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
33
To program an object-oriented solution begin by determining what ____ are needed in the solution.

A) data
B) objects
C) processes
D) methods
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
34
C# is an object-oriented language.All the code for an application must be placed in a(n)____.

A) file
B) object
C) class
D) method
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
35
Design your classes to be as flexible and full-featured as possible.One way to do this is to include multiple instance data members.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
36
Accessors are also referred to as ____.

A) mutators
B) properties
C) getters
D) classes
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
37
When you define the class,you describe its ____ in terms of data and its behaviors,or methods,in terms of what kinds of things it can do.

A) attributes
B) fields
C) characteristics
D) all of the above
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
38
Since the data members of the class are defined as private,their public property counterpart must be used to assign new values to the data members.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
39
When you create an application that has two files,both must have a Main( )method.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
40
Constructors should be defined with a ____ access modifier.

A) public
B) private
C) protected
D) static
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
41
The ToString( )method is automatically invoked when an object reference is made in the ____.

A) class constructor
B) Write( ) method
C) mutator method
D) object class
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
42
Which of the following is NOT one of the inherited member methods of the object class?

A) ToString( )
B) Equals( )
C) GetType( )
D) Main( )
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
43
Variables declared in the Main( )method are ____.

A) visible inside any method in the class.
B) are automatically initialized to zero.
C) must be defined as private data members.
D) only visible inside Main( ).
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
44
Instance methods manipulate data by ____.

A) directly accessing private data members.
B) passing information as arguments through parameters.
C) using constructors and accessors.
D) sending visible data in the Main( ) method.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
45
Normally data members are defined to have ____ access.

A) public
B) private
C) protected
D) internal
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
46
Constructors ____.

A) can be overloaded.
B) do not have to be written.
C) do not return a value.
D) all of the above.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
47
Accessors,mutators,and other instance methods are normally defined with what type of access modifier?

A) private
B) protected
C) internal
D) public
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
48
Instance methods are ____.

A) nonstatic methods.
B) also called class methods.
C) defined in the Main( ) method.
D) defined outside of the class.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
49
____ are special methods used to read the current state or value of an object member's data.

A) Accessors
B) Mutators
C) Constructors
D) Setters
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
50
What will be displayed from the above line?

A) Value = 12,346
B) Value = 12346
C) Value = 12,345
D) Value = 12,346.0
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
51
When you define a class,you can use ____ to display all public members of the class (once an object is instantiated).

A) constructors
B) intellisense
C) instance methods
D) class diagrams
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
52
If proper naming conventions were used in the above statement,which of the following statements is true?

A) PricePerSqYard is a property
B) plush is an object
C) 40.99 is a numeric literal
D) all of the above
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
53
Class methods manipulate data by ____.

A) directly accessing private data members.
B) passing information as arguments through parameters.
C) using constructors and accessors.
D) sending visible data in the Main( ) method.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
54
Which of the following is true regarding methods of a class?

A) You must use the keyword static.
B) They are called instance methods.
C) To call methods of the class in the class, you must prefix the method name with the class name.
D) No return type is used when you define a class method.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
55
To design a class that is flexible and full-featured,____.

A) define a constructor for every possible combination of data members.
B) define a default constructor.
C) define at least three constructors.
D) include multiple constructors.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
56
In order to provide a new definition for the ToString( )method,____.

A) it must be defined using the new operator.
B) there must be at least one constructor defined.
C) use the keyword override in the heading
D) both mutators and accessors must have been defined.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
57
Which of the following is NOT a true statement relating to constructors?

A) To add full functionality to your classes, write multiple constructors
B) If you write one constructor, you lose the default one that is created automatically.
C) The default constructor must be the first one written for the class.
D) Constructors are used to provide values to the object's data members.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
58
The static keyword must not be used with ____.

A) data members
B) instance methods
C) class methods
D) all of the above
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
59
To define a property to change a data member of a class include a ____ clause.

A) mutator
B) get
C) set
D) value
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
60
In order to test a class,____.

A) a different class is needed.
B) invoke instance methods using the objects you construct.
C) use the properties to assign and retrieve values.
D) all of the above.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
61
After the class diagram is created,add the names of data members or fields and methods
using the_________________ section.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
62
After a project has been created and a new class added to your application,you can use the ____________ Window in Visual Studio to create a class diagram.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
63
The ____________ constructor does not have any parameters and normally has no body,just opening and closing curly braces.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
64
The body of the constructor methods consist primarily of ____________.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
65
Fields or data members are also called ____________.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
66
Accessor and mutators are ____________ methods
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
67
As with overloaded methods,____________ must differ for constructors.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
68
By abstracting out the attributes (data)and the behaviors (processes on the data),you can create a(n)____________ to serve as a template from which many objects of that type can be instantiated.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
69
Data members should be defined with an access mode of ____________.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
70
C# is an object-oriented language as such all the code that you write has to be placed in a(n)____________.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
71
During the design phase,it is important to develop a(n)____________ illustrating what the desired final output should be.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
72
____________ access modifier is always associated with constructors.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
73
Constructors are used to ____________ a class.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
74
When you define the class,you describe its ____________,or characteristics or fields,in terms of data.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
75
If berber is an object,the statement Console.Write(berber);automatically invokes the ____________ method.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 75 flashcards in this deck.