Deck 6: Modularizing Your Code With Methods
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/61
Play
Full screen (f)
Deck 6: Modularizing Your Code With Methods
1
The ____________, which appears at the beginning of a method definition, lists several important things about the method, including the method's name.
A) method description
B) method body
C) method specification
D) method header
A) method description
B) method body
C) method specification
D) method header
D
2
When you call a ____________, it simply executes the statements it contains and then terminates.
A) void method
B) terminal method
C) value-returning method
D) private method
A) void method
B) terminal method
C) value-returning method
D) private method
A
3
A parameter variable, often simply called a(n)____________, is a special variable that receives an argument when a method is called.
A) parameter
B) argument
C) reference
D) variable
A) parameter
B) argument
C) reference
D) variable
A
4
When a method contains multiple parameter declarations, the declarations are often referred to as a(n) ____________.
A) variable cache
B) alternative collection
C) parameter list
D) overloaded reference
A) variable cache
B) alternative collection
C) parameter list
D) overloaded reference
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
5
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
A) camelCase
B) lowercase characters
C) Pascal case
D) uppercase characters
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
6
Which one of the following statements correctly calls a method named ShowName?
A) private void ShowName()
B) ShowName();
C) Call.ShowName();
D) ShowName;
A) private void ShowName()
B) ShowName();
C) Call.ShowName();
D) ShowName;
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
7
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
A) tiered project solution
B) method-based solution
C) modularized program
D) divisional program
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
8
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
A) programmatic simplification
B) divide and conquer
C) top down design
D) parallel design
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
9
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 literal value
C) a parameter list
D) passed by reference
A) passed by value
B) a literal value
C) a parameter list
D) passed by reference
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
10
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
A) passed by reference
B) passed by value
C) named
D) uninitialized
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
11
When a ____________ is provided for a parameter, it becomes 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
A) named argument
B) Boolean value
C) default argument
D) bitwise operator
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
12
The ____________ is a collection of statements that are performed when the method is executed.
A) method body
B) executable code
C) method header
D) method code listing
A) method body
B) executable code
C) method header
D) method code listing
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
13
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
A) method address
B) virtual break
C) return point
D) jump position
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
14
The benefit of using methods is known as ____________ because you are writing code to perform a task once and then reusing it each time you need to perform the task.
A) nominal assignment
B) minimal tasking
C) logic recycling
D) code reuse
A) nominal assignment
B) minimal tasking
C) logic recycling
D) code reuse
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
15
A parameter variable's scope is the ____________ in which the parameter variable is declared.
A) namespace
B) class
C) field
D) method
A) namespace
B) class
C) field
D) method
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
16
A method that contains 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
A) named argument
B) dynamic parameter
C) named constant
D) alternative argument
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
17
When you call a ____________, it executes the statements that it contains and then it returns a value back to the statement that called it.
A) recursive method
B) void method
C) value-returning method
D) public method
A) recursive method
B) void method
C) value-returning method
D) public method
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
18
Pieces of data that are sent into a method are known as ____________.
A) references
B) variables
C) arguments
D) parameters
A) references
B) variables
C) arguments
D) parameters
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
19
Programmers commonly use a technique known as ____________ to break down an algorithm into methods.
A) flowcharting
B) top-down design
C) modular prototyping
D) subtask recognition
A) flowcharting
B) top-down design
C) modular prototyping
D) subtask recognition
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
20
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) memory mapped
A) assignment compatible
B) user friendly
C) data bound
D) memory mapped
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
21
When working with value-returning methods, the data type of the value that the method returns is commonly called the method's ____________.
A) method value
B) named type
C) assigned value
D) return type
A) method value
B) named type
C) assigned value
D) return type
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
22
The method header is always terminated with a semicolon.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
23
When the keyword void appears in the method header, it means that the method will return a value.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
24
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
A) public method
B) value-returning method
C) void method
D) private method
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
25
In a general sense, a class is a collection of statements that performs a specific task.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
26
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
A) const
B) ref
C) out
D) private
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
27
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
A) parameter list
B) named argument
C) output parameter
D) named constant
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
28
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 61 flashcards in this deck.
Unlock Deck
k this deck
29
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
A) public
B) ref
C) const
D) out
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
30
____________ are useful for establishing two-way communication between methods.
A) Reference parameters
B) Named arguments
C) Default arguments
D) Parameter lists
A) Reference parameters
B) Named arguments
C) Default arguments
D) Parameter lists
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
31
A method definition has two parts: a header and a body.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
32
A value-returning statement must have a(n) ____________ statement.
A) return
B) assignment
C) logical
D) void
A) return
B) assignment
C) logical
D) void
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
33
Modularization tends to simplify code.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
34
You can use a(n) ____________ to test a condition, and then return either to indicate whether the condition exists..
A) reference parameter
B) Boolean method
C) if-else statement
D) void method
A) reference parameter
B) Boolean method
C) if-else statement
D) void method
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
35
In the header, the method name is always followed by a set of parentheses.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
36
Which of the following data types can be returned from a method?
A) int
B) bool
C) string
D) any of these
A) int
B) bool
C) string
D) any of these
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
37
Which of the following is the best choice for modularizing input validation?
A) Boolean methods
B) nested if statements
C) void methods
D) none of these
A) Boolean methods
B) nested if statements
C) void methods
D) none of these
Unlock Deck
Unlock for access to all 61 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 61 flashcards in this deck.
Unlock Deck
k this deck
39
To create a method you write its specification parameters.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
40
In general, the same rules that apply to variable names also apply to method names.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
41
Nested if statements can be useful for modularizing input validation.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
42
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 61 flashcards in this deck.
Unlock Deck
k this deck
43
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 61 flashcards in this deck.
Unlock Deck
k this deck
44
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 61 flashcards in this deck.
Unlock Deck
k this deck
45
You have to write the data type for each parameter variable that is declared in a parameter list.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
46
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 61 flashcards in this deck.
Unlock Deck
k this deck
47
The value that is returned from a method can be used like any other value.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
48
The top-down design process is sometimes called stepwise refinement.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
49
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 61 flashcards in this deck.
Unlock Deck
k this deck
50
Default arguments must be literals or constants.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
51
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 61 flashcards in this deck.
Unlock Deck
k this deck
52
You can pass only string arguments into string parameters.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
53
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 61 flashcards in this deck.
Unlock Deck
k this deck
54
The contents of variables and the values of expressions can be passed as arguments to a method.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
55
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 61 flashcards in this deck.
Unlock Deck
k this deck
56
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 61 flashcards in this deck.
Unlock Deck
k this deck
57
Default arguments were introduced in Visual C# 2010, so you cannot use them in older versions of C#.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
58
void methods are useful for simplifying complex conditions that are tested in decision and repetition structures.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
59
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 61 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 61 flashcards in this deck.
Unlock Deck
k this deck
61
You can write methods that return any type of data.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck