Deck 6: Modularizing Your Code with Methods

Full screen (f)
exit full mode
Question
A parameter variable's scope is the ____________ in which the parameter variable is declared.

A) namespace
B) class
C) field
D) method
Use Space or
up arrow
down arrow
to flip the card.
Question
When you pass an argument to a method, the argument's data type must be ____________ with the receiving parameter's data type.

A) assignment compatible
B) user friendly
C) data bound
D) identical to
Question
Which one of the following statements correctly calls a method named ShowName?

A) private void ShowName()
B) ShowName();
C) Call.ShowName();
D) ShowName;
Question
A __________ is a variable that receives an argument that is passed into a method.

A) parameter
B) argument
C) reference
D) none of these
Question
Data values passed a method when it is called are known as ____________.

A) references
B) variables
C) arguments
D) parameters
Question
When an argument is ____________, only a copy of the argument's value is passed into the parameter variable.

A) passed by reference
B) passed by value
C) named
D) uninitialized
Question
The ____________ is a collection of statements that are performed when a method is executed.

A) method body
B) executable code
C) method header
D) method code listing
Question
When you want a method to be able to change the value of a variable that is passed to it as an argument, the variable must be ____________.

A) passed by value
B) a value parameter
C) a variable parameter
D) passed by reference
Question
It is a standard convention among C# programmers to use ____________ for method names because it differentiates method names from variable and field names.

A) camelCase
B) lowercase characters
C) Pascal case
D) uppercase characters
Question
The memory address that is saved by the system when a method is called and is the location to which the system should return after a method ends is known as the ____________.

A) method address
B) virtual break
C) return point
D) jump position
Question
A method containing a(n) ____________ allows you to specify which parameter variable the argument should be passed to.

A) named argument
B) dynamic parameter
C) named constant
D) alternative argument
Question
When a ____________ is provided for a parameter, it is possible to call the method without explicitly passing an argument into the parameter.

A) named argument
B) Boolean value
C) default argument
D) bitwise operator
Question
When you call a ____________ method, it executes statements it contains and then returns a value back to the program statement that called it.

A) recursive
B) void
C) value-returning
D) public
Question
When a method contains multiple parameters, they are often referred to collectively as a(n) ____________.

A) reference list
B) parameter set
C) parameter list
D) argument list
Question
The benefit from dividing code into methods known as ____________ is gained as follows: After you write code to perform a task once, you can use the code again every time your program needs to perform the same task.

A) code recylcing
B) software engineering
C) logic recycling
D) code reuse
Question
When you call a ____________ method, it executes its code and returns without passing any value back to the program statement that called it.

A) void
B) terminal
C) value-returning
D) private
Question
Programmers commonly use a technique known as ____________ to divide an algorithm into smaller parts, which are then implemented as methods.

A) flowcharting
B) top-down design
C) modular prototyping
D) subtask recognition
Question
The ____________, which appears at the beginning of a method definition, lists several important things about the method, including the method's name and list of parameters.

A) method description
B) method body
C) method specification
D) method header
Question
In general terms, a program that is broken into smaller units of code such as methods, is known as a____________.

A) tiered project solution
B) method-based solution
C) modularized program
D) divisional program
Question
Dividing a large problem into several smaller problems that are easily solved is sometimes called ____________.

A) programmatic simplification
B) divide and conquer
C) top down design
D) parallel design
Question
A(n) ____________ works like a reference parameter, but the argument does not have to be set to a value before it is passed into the parameter.

A) parameter list
B) named argument
C) output parameter
D) named constant
Question
In C#, you declare a reference parameter by writing the ____________ keyword before the parameter variable's data type.

A) const
B) ref
C) out
D) private
Question
Every method must have a nonempty parameter list.
Question
When using the debugger, which command lets you immediately execute all remaining statements inside the current method, and return to the method's caller?

A) step out
B) step over
C) step into
D) step return
Question
When a ____________ finishes, it returns a value to the statement that called it.

A) public method
B) value-returning method
C) void method
D) private method
Question
You can use a(n) ____________ to test a conditional expression and return either

A) reference parameter
B) Boolean method
C) if-else statement
D) void method
Question
In a value-returning method, the type of data the method returns is commonly called the method's ____________.

A) method value
B) named type
C) assigned value
D) return type
Question
A value-returning statement must have a(n) ____________ statement.

A) return
B) assignment
C) logical
D) void
Question
Which of the following data types can be returned from a method?

A) int
B) bool
C) string
D) any of these
Question
When using the debugger, which command lets you execute a method call without seeing the individual statements within the method?

A) step out
B) step over
C) step into
D) step execute
Question
In C#, you declare an output parameter by writing the ____________ keyword before the parameter variable's data type.

A) public
B) ref
C) const
D) out
Question
If a specific task is performed in several places in a program, a method can be written once to perform that task and then be executed any time it is needed.
Question
Which of the following is the best type of tool for breaking up input validation into separate steps?

A) Boolean method
B) nested if statement
C) void method
D) none of these
Question
When the keyword void appears in the method header, it means the method will return a value.
Question
____________ are useful for returning more than one value from a method.

A) Reference parameters
B) Named arguments
C) Default arguments
D) Parameter lists
Question
In a general sense, a class is a collection of statements that performs a specific task.
Question
When using the debugger, which command lets you follow a method call into the statements in the method's source code?

A) step out
B) step over
C) step into
D) step trace
Question
The statements that make up the method body are enclosed inside a set of curly braces.
Question
A method definition has two parts: a header and a body.
Question
When a method is declared with the private access modifier, it can be called only by code inside the same class as the method.
Question
In general, the same naming rules that apply to variables also apply to methods.
Question
When you call a method that has a reference parameter, you must also write the keyword ref before the argument.
Question
Passing an argument by reference guarantees that the argument will not be changed by the method it is passed into.
Question
A mathematical expression such as A * B cannot be passed as an argument to a method containing a value parameter.
Question
When you pass an argument to a ref parameter, that argument must already be set to some value.
Question
The top-down design process is sometimes called stepwise engineering.
Question
Methods usually belong to a class, so you must write a method's definition inside the class to which it is supposed to belong.
Question
When a method is called, the program branches to that method and executes the statements in its body.
Question
Default arguments must be literals or constants.
Question
If you provide a default argument for the first parameter in a list, you do not need to provide default arguments for the remaining parameters.
Question
When calling a method and passing a variable as an argument, always write the data type and the variable name of the argument variable in the method call.
Question
A parameter variable can be accessed by any statement outside the method in which the parameter variable is declared.
Question
A mathematical expression such as A * B cannot be passed as an argument to a method containing a reference parameter.
Question
You can pass string literals as arguments to methods containing string parameters.
Question
The method header is always terminated with a semicolon.
Question
In a method header, the name is always followed by a set of parentheses.
Question
You can pass int arguments into int parameters, but you cannot pass double or decimal arguments into int parameters.
Question
You have to write the data type for each parameter variable in a parameter list.
Question
When you call a method that has an output parameter, you must also write the keyword out before the argument.
Question
If you are writing a method and you want it to receive arguments when it is called, you must equip the method with one or more access modifiers.
Question
The debugger's Step Into command lets you view all statements inside a method being called by the current program statement
Question
A method that has an output parameter must set the output parameter to some value before it finishes executing.
Question
Suppose you set a breakpoint inside a method named X. When you reach a statement that calls method X, the Step Over command will stop at the breakpoint.
Question
Suppose you're using the debugger to step through a method, and you want to immediately return to the place in the program where the method was called. The Step Return command will accomplish this.
Question
The debugger's Step Over command lets you view all statements inside a method being called by the current program statement.
Question
You can write methods that return any data type.
Question
void methods are useful for simplifying complex conditions that are tested in decision and repetition structures.
Question
When you call a method that has an output parameter, you do not need to assign an initial value to the argument variable.
Question
Nested if statements can be useful for modularizing input validation.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/69
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 6: Modularizing Your Code with Methods
1
A parameter variable's scope is the ____________ in which the parameter variable is declared.

A) namespace
B) class
C) field
D) method
D
2
When you pass an argument to a method, the argument's data type must be ____________ with the receiving parameter's data type.

A) assignment compatible
B) user friendly
C) data bound
D) identical to
A
3
Which one of the following statements correctly calls a method named ShowName?

A) private void ShowName()
B) ShowName();
C) Call.ShowName();
D) ShowName;
B
4
A __________ is a variable that receives an argument that is passed into a method.

A) parameter
B) argument
C) reference
D) none of these
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
5
Data values passed a method when it is called are known as ____________.

A) references
B) variables
C) arguments
D) parameters
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
6
When an argument is ____________, only a copy of the argument's value is passed into the parameter variable.

A) passed by reference
B) passed by value
C) named
D) uninitialized
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
7
The ____________ is a collection of statements that are performed when a method is executed.

A) method body
B) executable code
C) method header
D) method code listing
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
8
When you want a method to be able to change the value of a variable that is passed to it as an argument, the variable must be ____________.

A) passed by value
B) a value parameter
C) a variable parameter
D) passed by reference
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
9
It is a standard convention among C# programmers to use ____________ for method names because it differentiates method names from variable and field names.

A) camelCase
B) lowercase characters
C) Pascal case
D) uppercase characters
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
10
The memory address that is saved by the system when a method is called and is the location to which the system should return after a method ends is known as the ____________.

A) method address
B) virtual break
C) return point
D) jump position
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
11
A method containing a(n) ____________ allows you to specify which parameter variable the argument should be passed to.

A) named argument
B) dynamic parameter
C) named constant
D) alternative argument
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
12
When a ____________ is provided for a parameter, it is possible to call the method without explicitly passing an argument into the parameter.

A) named argument
B) Boolean value
C) default argument
D) bitwise operator
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
13
When you call a ____________ method, it executes statements it contains and then returns a value back to the program statement that called it.

A) recursive
B) void
C) value-returning
D) public
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
14
When a method contains multiple parameters, they are often referred to collectively as a(n) ____________.

A) reference list
B) parameter set
C) parameter list
D) argument list
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
15
The benefit from dividing code into methods known as ____________ is gained as follows: After you write code to perform a task once, you can use the code again every time your program needs to perform the same task.

A) code recylcing
B) software engineering
C) logic recycling
D) code reuse
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
16
When you call a ____________ method, it executes its code and returns without passing any value back to the program statement that called it.

A) void
B) terminal
C) value-returning
D) private
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
17
Programmers commonly use a technique known as ____________ to divide an algorithm into smaller parts, which are then implemented as methods.

A) flowcharting
B) top-down design
C) modular prototyping
D) subtask recognition
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
18
The ____________, which appears at the beginning of a method definition, lists several important things about the method, including the method's name and list of parameters.

A) method description
B) method body
C) method specification
D) method header
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
19
In general terms, a program that is broken into smaller units of code such as methods, is known as a____________.

A) tiered project solution
B) method-based solution
C) modularized program
D) divisional program
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
20
Dividing a large problem into several smaller problems that are easily solved is sometimes called ____________.

A) programmatic simplification
B) divide and conquer
C) top down design
D) parallel design
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
21
A(n) ____________ works like a reference parameter, but the argument does not have to be set to a value before it is passed into the parameter.

A) parameter list
B) named argument
C) output parameter
D) named constant
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
22
In C#, you declare a reference parameter by writing the ____________ keyword before the parameter variable's data type.

A) const
B) ref
C) out
D) private
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
23
Every method must have a nonempty parameter list.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
24
When using the debugger, which command lets you immediately execute all remaining statements inside the current method, and return to the method's caller?

A) step out
B) step over
C) step into
D) step return
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
25
When a ____________ finishes, it returns a value to the statement that called it.

A) public method
B) value-returning method
C) void method
D) private method
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
26
You can use a(n) ____________ to test a conditional expression and return either

A) reference parameter
B) Boolean method
C) if-else statement
D) void method
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
27
In a value-returning method, the type of data the method returns is commonly called the method's ____________.

A) method value
B) named type
C) assigned value
D) return type
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
28
A value-returning statement must have a(n) ____________ statement.

A) return
B) assignment
C) logical
D) void
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
29
Which of the following data types can be returned from a method?

A) int
B) bool
C) string
D) any of these
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
30
When using the debugger, which command lets you execute a method call without seeing the individual statements within the method?

A) step out
B) step over
C) step into
D) step execute
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
31
In C#, you declare an output parameter by writing the ____________ keyword before the parameter variable's data type.

A) public
B) ref
C) const
D) out
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
32
If a specific task is performed in several places in a program, a method can be written once to perform that task and then be executed any time it is needed.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
33
Which of the following is the best type of tool for breaking up input validation into separate steps?

A) Boolean method
B) nested if statement
C) void method
D) none of these
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
34
When the keyword void appears in the method header, it means the method will return a value.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
35
____________ are useful for returning more than one value from a method.

A) Reference parameters
B) Named arguments
C) Default arguments
D) Parameter lists
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
36
In a general sense, a class is a collection of statements that performs a specific task.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
37
When using the debugger, which command lets you follow a method call into the statements in the method's source code?

A) step out
B) step over
C) step into
D) step trace
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
38
The statements that make up the method body are enclosed inside a set of curly braces.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
39
A method definition has two parts: a header and a body.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
40
When a method is declared with the private access modifier, it can be called only by code inside the same class as the method.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
41
In general, the same naming rules that apply to variables also apply to methods.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
42
When you call a method that has a reference parameter, you must also write the keyword ref before the argument.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
43
Passing an argument by reference guarantees that the argument will not be changed by the method it is passed into.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
44
A mathematical expression such as A * B cannot be passed as an argument to a method containing a value parameter.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
45
When you pass an argument to a ref parameter, that argument must already be set to some value.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
46
The top-down design process is sometimes called stepwise engineering.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
47
Methods usually belong to a class, so you must write a method's definition inside the class to which it is supposed to belong.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
48
When a method is called, the program branches to that method and executes the statements in its body.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
49
Default arguments must be literals or constants.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
50
If you provide a default argument for the first parameter in a list, you do not need to provide default arguments for the remaining parameters.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
51
When calling a method and passing a variable as an argument, always write the data type and the variable name of the argument variable in the method call.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
52
A parameter variable can be accessed by any statement outside the method in which the parameter variable is declared.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
53
A mathematical expression such as A * B cannot be passed as an argument to a method containing a reference parameter.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
54
You can pass string literals as arguments to methods containing string parameters.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
55
The method header is always terminated with a semicolon.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
56
In a method header, the name is always followed by a set of parentheses.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
57
You can pass int arguments into int parameters, but you cannot pass double or decimal arguments into int parameters.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
58
You have to write the data type for each parameter variable in a parameter list.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
59
When you call a method that has an output parameter, you must also write the keyword out before the argument.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
60
If you are writing a method and you want it to receive arguments when it is called, you must equip the method with one or more access modifiers.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
61
The debugger's Step Into command lets you view all statements inside a method being called by the current program statement
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
62
A method that has an output parameter must set the output parameter to some value before it finishes executing.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
63
Suppose you set a breakpoint inside a method named X. When you reach a statement that calls method X, the Step Over command will stop at the breakpoint.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
64
Suppose you're using the debugger to step through a method, and you want to immediately return to the place in the program where the method was called. The Step Return command will accomplish this.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
65
The debugger's Step Over command lets you view all statements inside a method being called by the current program statement.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
66
You can write methods that return any data type.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
67
void methods are useful for simplifying complex conditions that are tested in decision and repetition structures.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
68
When you call a method that has an output parameter, you do not need to assign an initial value to the argument variable.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
69
Nested if statements can be useful for modularizing input validation.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 69 flashcards in this deck.