Deck 3: Methods and Behaviors

Full screen (f)
exit full mode
Question
The name of the method,modifiers,return type,and the types of its formal parameters make up the signature of the method.
Use Space or
up arrow
down arrow
to flip the card.
Question
A standard convention used by programmers for naming classes is to use an action verb phrase.
Question
Methods may be defined in any order and placed anywhere in the file,in or outside of the class.
Question
A standard convention used by C# programmers is to use Pascal case style for class,data member identifiers,and method identifiers.
Question
Methods are the members of a class that perform an action,and through writing methods you describe the behavior of data.
Question
The accessibility modifier identifies what type of value is returned when the method is completed.
Question
The entries found inside the parentheses of the method heading are called the access modifiers.
Question
The body of a method can include statements that declare other methods.
Question
If a method does not return a value,the void keyword is placed inside the parentheses in the method heading.
Question
The Read( )method is different from the ReadLine( )method in that the Read( )returns an int and the ReadLine( )returns a string argument.
Question
A semicolon is placed on the end of a method heading following the parameter list.
Question
Console applications require a Main( )method,unlike Windows applications that do not require a Main( )method.
Question
One required entry for a method heading is the return type.
Question
The definition of the method includes the entry inside the curly braces,which is sometimes called the body of the method.
Question
In order to hold the screen when the program runs,programmers often add Console.Read( )as a last statement.
Question
The Console class is defined in the System namespace.
Question
The following are examples of the access modifiers available in C#: public,personal,protected.
Question
In order to call a static method from another class,the class name must be used with the method name.
Question
The Write( ),WriteLine( ),Read( ),and ReadLine( )methods are all overloaded.
Question
In order to indicate a value is constant and cannot be changed,the keyword constant is added.
Question
The definition of the method ____.

A) is the same as the heading for the method
B) is the body of the method
C) includes everything between the curly braces
D) includes the heading and the body
Question
The most restrictive access modifier that offers accessibility only within the body of the class is ____.

A) internal
B) public
C) protected
D) private
Question
Ceiling( ),Pow( ),and Floor( )are all static members of the Console class.
Question
Console.WriteLine("Final Grade = {0:N2}",
CalculateGrade(90, 75, 83));
In the statement above,CalculateGrade(90,75,83)is ____.

A) a method call
B) a method declaration
C) an identifier for the class
D) a parameter for the WriteLine( ) method
Question
The return type is physically placed ____.

A) immediately preceding the name of the method
B) inside the method
C) as the first entry in the method heading
D) immediately following the name of the method
Question
Both out and ref parameter types cause a method to refer to the same variable that was passed into the method.
Question
Methods that use the static modifier are called class methods.
Question
Console.WriteLine("Final Grade = {0:N2}",
CalculateGrade(90, 75, 83));
The {0:N2} above indicates the ____.

A) first argument should display no digits to the right of the decimal
B) first argument should display two digits to the right of the decimal
C) the argument should be displayed with 0 digits to the left of the decimal and two digits to the right of the decimal
D) the argument should be displayed with 0 digits to the right of the decimal and two digits to the left of the decimal
Question
The definition for a method includes just the heading.The signature includes the heading and the body of the method.
Question
The Parse( )method returns the number representation of its string argument.
Question
Console.WriteLine("Final Grade = {0:N2}",
CalculateGrade(90, 75, 83));
In the statement above,the values placed inside the parentheses following CalculateGrade are ____.

A) arguments to the method
B) formal parameters of the method
C) printed at runtime
D) values being returned from the method
Question
C# offers both call by value and call by reference parameters.Call by value is the default type.
Question
Which of the following is a user-defined method?

A) Parse( )
B) Write( )
C) Main( )
D) Pow( )
Question
____ is added to hold the screen when the program runs.

A) Hold( )
B) return
C) Read( )
D) Pause( )
Question
A namespace is really nothing more than a group of statements placed together under a single
name.
Question
Methods can be defined globally outside of a class in C#.
Question
One way to ensure that you have one entry and one exit from a method is to include a single return statement as the last statement in the method.
Question
When a distinction is made between parameters and arguments,____.

A) actual arguments appear in the method heading
B) parameters are the values used to call the method
C) formal parameters appear in the method heading
D) actual arguments are part of the formal parameters
Question
The first line of a method is called the ____ of the method.

A) signature
B) definition
C) heading
D) declaration
Question
The return keyword may not be included with a non-value returning method (void method).
Question
The Math class has a number of static methods located in the _____________ namespace.

A) Math
B) System
C) IO
D) Arithmetic
Question
Method names should be defined with meaningful names using ____.

A) camel case
B) singular nouns
C) upper case characters
D) verb phrases
Question
The ____ of an identifier is the region of the program in which that identifier is usable.

A) access
B) scope
C) modifier
D) declaration
Question
The ____ specifies what kind of information is returned when the body of the method is finished executing.

A) access modifiers
B) parameters
C) static modifier
D) returnType
Question
The return type for the method above is ____.

A) public
B) static
C) void
D) Main( )
Question
The ____ parameter type cannot be used unless the original argument is initialized before it is sent to the method.

A) ref
B) in
C) out
D) params
Question
A method that does not return any value on exit,____.

A) must be called with the void keyword
B) cannot include the return keyword
C) must be defined to have a void return type
D) is not allowed in C#
Question
A method used to convert from one base type to another is ____.

A) ChangeValue( )
B) Convert( )
C) ToDouble( )
D) Convert.ToDouble( )
Question
The result of the call to Math.Pow( )in the above statement is to store ________ in answer:

A) 9
B) 3, 2
C) 6
D) an error message
Question
The following members of the Math class,(Round( ),Max( ),Exp( )),must be called using the class name,because they are all ____.

A) static methods
B) objects
C) predefined methods
D) private methods
Question
Which of the following would be a valid call to the above method?

A) answer = Abs(-23);
B) answer = int Math.Abs(-23)
C) answer = Math.Abs(-23)
D) answer = int Abs(-23)
Question
Calls to ____ methods use the class identifier instead of the object identifier as the method qualifier.

A) value returning
B) static
C) private
D) predefined
Question
Which method returns the largest whole number less than or equal to the specified number?

A) Max( )
B) Ceiling( )
C) Floor( )
D) Largest( )
Question
In order to call or invoke a nonvalue-returning method,enter the ____.

A) access modifier followed by the method identifier and list of arguments
B) return type followed by the method identifier and list of parameters
C) method's identifier followed by list of arguments
D) access modifier, return type, and method's identifier followed by list of parameters
Question
When you assign a default value to a parameter,it then becomes a(n): ____.

A) named parameter
B) static parameter
C) method parameter
D) optional parameter
Question
An advantage of using named parameters is: ____.

A) program runs more efficiently because the named parameters can be accessed
B) program runs faster
C) you can send in values through using the names of the parameters instead of having to worry about getting the exact order
D) default values can be used
Question
Which of the following methods are not overloaded?

A) WriteLine( )
B) Write( )
C) ReadLine( )
D) Abs( )
Question
The Read( )method ____.

A) is a nonvalue-returning method
B) returns a string
C) returns a single char
D) returns an int
Question
The access modifier in the heading above is the keyword ____.

A) public
B) static
C) void
D) Main( )
Question
Which of the following is NOT a parameter type?

A) out
B) in
C) ref
D) params
Question
____________ is an overloaded method of the Math class that returns the larger of two
specified numbers.
Question
_____________access offers the fewest access limitations;there are basically no restrictions on accessing ____________ members or classes.
Question
When naming a(n)____________,use an action verb phrase.
Question
When you assign a default value to a parameter,it then becomes a(n)____________ parameter.
Question
Call by ____________ is the default parameter type.
Question
When a class or a class member does not specify a modifier,the default accessibility
level of _______________ is assumed.
Question
The ____________ type is always listed immediately preceding the name of the method.
Question
All programs consist of at least one ____________.
Question
The term ____________ is often used to indicate where an identifier has meaning and can be used
Question
Avoid writing long methods.Consider refactoring when the method exceeds ____________ lines of code
Question
All Main( )method headings must include the ____________ modifier meaning that the method belongs to the type itself rather than to a specific object of a class.
Question
Calls to ____________ methods must be placed at a location in your code where the value could be accepted when the method is finished.
Question
When naming local variable identifiers and parameters,use ____________.
Question
One option to holding the screen at the end of a program is to invoke Console.Read( ).Another option is to call ____________.It obtains the next character or function key from the user.
Question
____________ is used to indicate that no value is being returned from a 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 3: Methods and Behaviors
1
The name of the method,modifiers,return type,and the types of its formal parameters make up the signature of the method.
False
2
A standard convention used by programmers for naming classes is to use an action verb phrase.
False
3
Methods may be defined in any order and placed anywhere in the file,in or outside of the class.
False
4
A standard convention used by C# programmers is to use Pascal case style for class,data member identifiers,and method identifiers.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
5
Methods are the members of a class that perform an action,and through writing methods you describe the behavior of data.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
6
The accessibility modifier identifies what type of value is returned when the method is completed.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
7
The entries found inside the parentheses of the method heading are called the access modifiers.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
8
The body of a method can include statements that declare other methods.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
9
If a method does not return a value,the void keyword is placed inside the parentheses in the method heading.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
10
The Read( )method is different from the ReadLine( )method in that the Read( )returns an int and the ReadLine( )returns a string argument.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
11
A semicolon is placed on the end of a method heading following the parameter list.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
12
Console applications require a Main( )method,unlike Windows applications that do not require a Main( )method.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
13
One required entry for a method heading is the return type.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
14
The definition of the method includes the entry inside the curly braces,which is sometimes called the body of the method.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
15
In order to hold the screen when the program runs,programmers often add Console.Read( )as a last statement.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
16
The Console class is defined in the System namespace.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
17
The following are examples of the access modifiers available in C#: public,personal,protected.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
18
In order to call a static method from another class,the class name must be used with the method name.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
19
The Write( ),WriteLine( ),Read( ),and ReadLine( )methods are all overloaded.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
20
In order to indicate a value is constant and cannot be changed,the keyword constant is added.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
21
The definition of the method ____.

A) is the same as the heading for the method
B) is the body of the method
C) includes everything between the curly braces
D) includes the heading and the body
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
22
The most restrictive access modifier that offers accessibility only within the body of the class is ____.

A) internal
B) public
C) protected
D) private
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
23
Ceiling( ),Pow( ),and Floor( )are all static members of the Console class.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
24
Console.WriteLine("Final Grade = {0:N2}",
CalculateGrade(90, 75, 83));
In the statement above,CalculateGrade(90,75,83)is ____.

A) a method call
B) a method declaration
C) an identifier for the class
D) a parameter for the WriteLine( ) method
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
25
The return type is physically placed ____.

A) immediately preceding the name of the method
B) inside the method
C) as the first entry in the method heading
D) immediately following the name of the method
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
26
Both out and ref parameter types cause a method to refer to the same variable that was passed into the method.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
27
Methods that use the static modifier are called class methods.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
28
Console.WriteLine("Final Grade = {0:N2}",
CalculateGrade(90, 75, 83));
The {0:N2} above indicates the ____.

A) first argument should display no digits to the right of the decimal
B) first argument should display two digits to the right of the decimal
C) the argument should be displayed with 0 digits to the left of the decimal and two digits to the right of the decimal
D) the argument should be displayed with 0 digits to the right of the decimal and two digits to the left of the decimal
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
29
The definition for a method includes just the heading.The signature includes the heading and the body of the method.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
30
The Parse( )method returns the number representation of its string argument.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
31
Console.WriteLine("Final Grade = {0:N2}",
CalculateGrade(90, 75, 83));
In the statement above,the values placed inside the parentheses following CalculateGrade are ____.

A) arguments to the method
B) formal parameters of the method
C) printed at runtime
D) values being returned from the method
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
32
C# offers both call by value and call by reference parameters.Call by value is the default type.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
33
Which of the following is a user-defined method?

A) Parse( )
B) Write( )
C) Main( )
D) Pow( )
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
34
____ is added to hold the screen when the program runs.

A) Hold( )
B) return
C) Read( )
D) Pause( )
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
35
A namespace is really nothing more than a group of statements placed together under a single
name.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
36
Methods can be defined globally outside of a class in C#.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
37
One way to ensure that you have one entry and one exit from a method is to include a single return statement as the last statement in the method.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
38
When a distinction is made between parameters and arguments,____.

A) actual arguments appear in the method heading
B) parameters are the values used to call the method
C) formal parameters appear in the method heading
D) actual arguments are part of the formal parameters
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
39
The first line of a method is called the ____ of the method.

A) signature
B) definition
C) heading
D) declaration
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
40
The return keyword may not be included with a non-value returning method (void method).
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
41
The Math class has a number of static methods located in the _____________ namespace.

A) Math
B) System
C) IO
D) Arithmetic
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
42
Method names should be defined with meaningful names using ____.

A) camel case
B) singular nouns
C) upper case characters
D) verb phrases
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
43
The ____ of an identifier is the region of the program in which that identifier is usable.

A) access
B) scope
C) modifier
D) declaration
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
44
The ____ specifies what kind of information is returned when the body of the method is finished executing.

A) access modifiers
B) parameters
C) static modifier
D) returnType
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
45
The return type for the method above is ____.

A) public
B) static
C) void
D) Main( )
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
46
The ____ parameter type cannot be used unless the original argument is initialized before it is sent to the method.

A) ref
B) in
C) out
D) params
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
47
A method that does not return any value on exit,____.

A) must be called with the void keyword
B) cannot include the return keyword
C) must be defined to have a void return type
D) is not allowed in C#
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
48
A method used to convert from one base type to another is ____.

A) ChangeValue( )
B) Convert( )
C) ToDouble( )
D) Convert.ToDouble( )
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
49
The result of the call to Math.Pow( )in the above statement is to store ________ in answer:

A) 9
B) 3, 2
C) 6
D) an error message
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
50
The following members of the Math class,(Round( ),Max( ),Exp( )),must be called using the class name,because they are all ____.

A) static methods
B) objects
C) predefined methods
D) private methods
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
51
Which of the following would be a valid call to the above method?

A) answer = Abs(-23);
B) answer = int Math.Abs(-23)
C) answer = Math.Abs(-23)
D) answer = int Abs(-23)
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
52
Calls to ____ methods use the class identifier instead of the object identifier as the method qualifier.

A) value returning
B) static
C) private
D) predefined
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
53
Which method returns the largest whole number less than or equal to the specified number?

A) Max( )
B) Ceiling( )
C) Floor( )
D) Largest( )
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
54
In order to call or invoke a nonvalue-returning method,enter the ____.

A) access modifier followed by the method identifier and list of arguments
B) return type followed by the method identifier and list of parameters
C) method's identifier followed by list of arguments
D) access modifier, return type, and method's identifier followed by list of parameters
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
55
When you assign a default value to a parameter,it then becomes a(n): ____.

A) named parameter
B) static parameter
C) method parameter
D) optional parameter
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
56
An advantage of using named parameters is: ____.

A) program runs more efficiently because the named parameters can be accessed
B) program runs faster
C) you can send in values through using the names of the parameters instead of having to worry about getting the exact order
D) default values can be used
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
57
Which of the following methods are not overloaded?

A) WriteLine( )
B) Write( )
C) ReadLine( )
D) Abs( )
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
58
The Read( )method ____.

A) is a nonvalue-returning method
B) returns a string
C) returns a single char
D) returns an int
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
59
The access modifier in the heading above is the keyword ____.

A) public
B) static
C) void
D) Main( )
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
60
Which of the following is NOT a parameter type?

A) out
B) in
C) ref
D) params
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
61
____________ is an overloaded method of the Math class that returns the larger of two
specified numbers.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
62
_____________access offers the fewest access limitations;there are basically no restrictions on accessing ____________ members or classes.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
63
When naming a(n)____________,use an action verb phrase.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
64
When you assign a default value to a parameter,it then becomes a(n)____________ parameter.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
65
Call by ____________ is the default parameter type.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
66
When a class or a class member does not specify a modifier,the default accessibility
level of _______________ is assumed.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
67
The ____________ type is always listed immediately preceding the name of the method.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
68
All programs consist of at least one ____________.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
69
The term ____________ is often used to indicate where an identifier has meaning and can be used
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
70
Avoid writing long methods.Consider refactoring when the method exceeds ____________ lines of code
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
71
All Main( )method headings must include the ____________ modifier meaning that the method belongs to the type itself rather than to a specific object of a class.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
72
Calls to ____________ methods must be placed at a location in your code where the value could be accepted when the method is finished.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
73
When naming local variable identifiers and parameters,use ____________.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
74
One option to holding the screen at the end of a program is to invoke Console.Read( ).Another option is to call ____________.It obtains the next character or function key from the user.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
75
____________ is used to indicate that no value is being returned from a 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.