Deck 3: Methods and Behaviors

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

A) Parse( )
B) Write( )
C) Main( )
D) Pow( )
Question
Methods can be defined globally outside of a class in C#.
Question
____ is added to hold the screen when the program runs.

A) Hold( )
B) return
C) Read( )
D) Pause( )
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
The first line of a method is called the ____ of the method.

A) signature
B) definition
C) heading
D) declaration
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
Ceiling( ), Pow( ), and Floor( ) are all static members of the Console class.
Question
Both out and ref parameter types cause a method to refer to the same variable that was passed into the method.
Question
The Parse( ) method returns the number representation of its string argument.
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
C# offers both call by value and call by reference parameters. Call by value is the default type.
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 return keyword may not be included with a non-value returning method (void method).
Question
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
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
Methods that use the static modifier are called class methods.
Question
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
A namespace is really nothing more than a group of statements placed together under a single
name.
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
The Math class has a number of static methods located in the ____ namespace.

A) Math
B) System
C) IO
D) Arithmetic
Question
double answer = Math.Pow(3, 2);
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
public static int Abs(int)
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
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
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
Method names should be defined with meaningful names using ____.

A) camel case
B) singular nouns
C) upper case characters
D) verb phrases
Question
Which of the following is NOT a parameter type?

A) out
B) in
C) ref
D) params
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
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
public static void Main( )
The access modifier in the heading above is the keyword ____.

A) public
B) static
C) void
D) Main( )
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
Unless a using statement is added to include the Math class, calls to members like Round( ), Max( ), and 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 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
public static void Main( )
The return type for the method above is ____.

A) public
B) static
C) void
D) Main( )
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
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 primary difference between call by reference using ref versus out is ____.

A) ​ref requires the original argument be initialized, out doesn't
B) ​out can only be used with integral memory types, ref can be used with any type
C) ​ref requires the keyword ref be included in the call and heading, out doesn't
D) ​ref is pass by reference
Question
All programs consist of at least one ____________.
Question
Every method that has a return type other than ________ must have a return statement in the body.
Question
When naming a(n) ____________, use an action verb phrase.
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
The ____________ type is always listed immediately preceding the name of the method.
Question
____________ is an overloaded method of the Math class that returns the larger of two
specified numbers.
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
The term ____________ is often used to indicate where an identifier has meaning and can be used
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
When you assign a default value to a parameter, it then becomes a(n) ____________ parameter.
Question
Call by ____________ is the default parameter type.
Question
Avoid writing long methods. Consider refactoring when the method exceeds ____________ lines of code
Question
When naming local variable identifiers and parameters, use ____________.
Question
Methods that use the static m odifier are called _________ methods.
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
A semicolon is placed on the end of a method heading following the parameter list.
False
2
The entries found inside the parentheses of the method heading are called the access modifiers.
False
3
The definition of the method includes the entry inside the curly braces, which is sometimes called the body of the method.
False
4
A standard convention used by programmers for naming classes is to use an action verb phrase.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
5
In order to hold the screen when the program runs, programmers often add ReadKey( ) as a last statement.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
6
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
7
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
8
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
9
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
10
Methods may be defined in any order and placed anywhere in the file, in or outside of the class.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
11
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
12
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
13
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
14
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
15
The name of the method, modifiers, return type, and the types of its formal parameters make up the signature of the method.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
16
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
17
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
18
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
19
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
20
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
21
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
22
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
23
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
24
____ 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
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
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
27
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
28
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
29
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
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
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
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
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
34
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
35
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
36
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
37
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
38
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
39
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
40
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
41
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
42
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
43
double answer = Math.Pow(3, 2);
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
44
public static int Abs(int)
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
45
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
46
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
47
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
48
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
49
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
50
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
51
public static void Main( )
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
52
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
53
Unless a using statement is added to include the Math class, calls to members like Round( ), Max( ), and 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
54
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
55
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
56
public static void Main( )
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
57
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
58
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
59
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
60
The primary difference between call by reference using ref versus out is ____.

A) ​ref requires the original argument be initialized, out doesn't
B) ​out can only be used with integral memory types, ref can be used with any type
C) ​ref requires the keyword ref be included in the call and heading, out doesn't
D) ​ref is pass by reference
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
61
All programs consist of at least one ____________.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
62
Every method that has a return type other than ________ must have a return statement in the body.
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
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
65
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
66
____________ 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
67
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
68
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
69
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
70
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
71
Call by ____________ is the default parameter type.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
72
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
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
Methods that use the static m odifier are called _________ methods.
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.