Deck 7: Using Methods

Full screen (f)
exit full mode
Question
With ____, if a programmer changes the way in which a method internally works, programs that use that method will not be affected and will not need to be modified.

A) overloading
B) implementation hiding
C) polymorphism
D) inheritance
Use Space or
up arrow
down arrow
to flip the card.
Question
Because the ReadLine() method call can be assigned to a string, its return type is ____ .

A) int
B) Object
C) bool
D) string
Question
The type of an argument in a method call must exactly match the type of the corresponding parameter specified in the method declaration.
Question
If you use the keyword modifier ____, you indicate that a method can be called by referring to the class rather than an object from the class.

A) static
B) internal
C) protected
D) nonstatic
Question
A method ____ is a variable that holds data passed to the method when it is called; it receives an argument's value when the method executes.

A) element
B) parameter
C) literal
D) declaration
Question
The ____ accessibility modifier allows access to a method from other classes.

A) public
B) protected
C) private
D) protected internal
Question
A program element's ____ is the segment of code in which it can be used.

A) scope
B) locality
C) accessibility
D) nesting
Question
A declaration for a method that receives two or more arguments must list the type for each parameter separately only if the parameters have different types.
Question
A parameter within a method header is called a(n) ____ parameter.

A) formal
B) local
C) global
D) actual
Question
A method can return, at most, one value to a method that calls it.
Question
To more easily incorporate methods into a program, it is common practice to store methods in their own classes and files. Then you can add them into any application that uses them. The resulting compound program is called a(n) ____.

A) interface
B) multifile assembly
C) hid assembly
D) hid implementation
Question
A(n) ____ is a device you can use without knowing how it works internally.

A) white box
B) interface
C) black box
D) method
Question
Methods can ____, or call, other methods; that is, a program uses a method's name and the method performs a job for the class.

A) instantiate
B) overload
C) inherit
D) invoke
Question
The ____ accessibility modifier limits method access to the class that contains the method.

A) protected
B) private
C) protected internal
D) internal
Question
If you do not provide an accessibility modifier for a method, it is private by default.
Question
A method that uses another is called a ____ of the method it uses.

A) peer
B) server
C) pair
D) client
Question
The number of arguments does not need to match the number in the parameter list when you use ____.

A) default arguments
B) value parameters
C) scope relaxation
D) non-critical parameters
Question
Arrays, like all objects, are passed by value.
Question
The optional declared ____ for a method (for example, public ) sets limits as to how other methods can use it.

A) protection
B) qualifier
C) accessibility
D) type
Question
A formal parameter that receives a copy of the value passed to it is also an example of a(n) ____ parameter.

A) reference
B) output
C) input
D) value
Question
What are the components of a C# method declaration?
Question
Match between columns
Receives a copy of the value passed to it
parameter list
Receives a copy of the value passed to it
fully qualified name
Receives a copy of the value passed to it
value parameter
Receives a copy of the value passed to it
nonstatic method
Receives a copy of the value passed to it
local variable
Receives a copy of the value passed to it
calling method
Receives a copy of the value passed to it
field
Receives a copy of the value passed to it
bool
Receives a copy of the value passed to it
object's starting memory address
Optionally present within parentheses after the method name in a method declaration
parameter list
Optionally present within parentheses after the method name in a method declaration
fully qualified name
Optionally present within parentheses after the method name in a method declaration
value parameter
Optionally present within parentheses after the method name in a method declaration
nonstatic method
Optionally present within parentheses after the method name in a method declaration
local variable
Optionally present within parentheses after the method name in a method declaration
calling method
Optionally present within parentheses after the method name in a method declaration
field
Optionally present within parentheses after the method name in a method declaration
bool
Optionally present within parentheses after the method name in a method declaration
object's starting memory address
Can only be used in conjunction with an object
parameter list
Can only be used in conjunction with an object
fully qualified name
Can only be used in conjunction with an object
value parameter
Can only be used in conjunction with an object
nonstatic method
Can only be used in conjunction with an object
local variable
Can only be used in conjunction with an object
calling method
Can only be used in conjunction with an object
field
Can only be used in conjunction with an object
bool
Can only be used in conjunction with an object
object's starting memory address
One that calls another method
parameter list
One that calls another method
fully qualified name
One that calls another method
value parameter
One that calls another method
nonstatic method
One that calls another method
local variable
One that calls another method
calling method
One that calls another method
field
One that calls another method
bool
One that calls another method
object's starting memory address
A method's complete name including its class
parameter list
A method's complete name including its class
fully qualified name
A method's complete name including its class
value parameter
A method's complete name including its class
nonstatic method
A method's complete name including its class
local variable
A method's complete name including its class
calling method
A method's complete name including its class
field
A method's complete name including its class
bool
A method's complete name including its class
object's starting memory address
The return type for a method that returns either true or false
parameter list
The return type for a method that returns either true or false
fully qualified name
The return type for a method that returns either true or false
value parameter
The return type for a method that returns either true or false
nonstatic method
The return type for a method that returns either true or false
local variable
The return type for a method that returns either true or false
calling method
The return type for a method that returns either true or false
field
The return type for a method that returns either true or false
bool
The return type for a method that returns either true or false
object's starting memory address
What is received by an invoked method when an object is passed to it by reference
parameter list
What is received by an invoked method when an object is passed to it by reference
fully qualified name
What is received by an invoked method when an object is passed to it by reference
value parameter
What is received by an invoked method when an object is passed to it by reference
nonstatic method
What is received by an invoked method when an object is passed to it by reference
local variable
What is received by an invoked method when an object is passed to it by reference
calling method
What is received by an invoked method when an object is passed to it by reference
field
What is received by an invoked method when an object is passed to it by reference
bool
What is received by an invoked method when an object is passed to it by reference
object's starting memory address
This kind of variable is declared within a method and is not known to other methods
parameter list
This kind of variable is declared within a method and is not known to other methods
fully qualified name
This kind of variable is declared within a method and is not known to other methods
value parameter
This kind of variable is declared within a method and is not known to other methods
nonstatic method
This kind of variable is declared within a method and is not known to other methods
local variable
This kind of variable is declared within a method and is not known to other methods
calling method
This kind of variable is declared within a method and is not known to other methods
field
This kind of variable is declared within a method and is not known to other methods
bool
This kind of variable is declared within a method and is not known to other methods
object's starting memory address
A variable declared within a class but outside of the class's methods
parameter list
A variable declared within a class but outside of the class's methods
fully qualified name
A variable declared within a class but outside of the class's methods
value parameter
A variable declared within a class but outside of the class's methods
nonstatic method
A variable declared within a class but outside of the class's methods
local variable
A variable declared within a class but outside of the class's methods
calling method
A variable declared within a class but outside of the class's methods
field
A variable declared within a class but outside of the class's methods
bool
A variable declared within a class but outside of the class's methods
object's starting memory address
Question
What are the components of a C# method?
Question
Every method has a(n) ____________________, indicating what kind of value the method will return to any other method that calls it.
Question
You indicate that a method parameter is an array by placing ____ after the data type in the method's parameter list.

A) ()
B) $
C) []
D) {}
Question
The keyword static is used with Main() methods in console applications because the method is associated with its containing class and not with an object. Why are Form methods, such as a Click() method that responds to button clicks, nonstatic?
Question
You can tell a lot about a built-in method when you see how it is used. What can you tell about the built-in Pow() method (used to raise a number to a power) from the following statement?
double result = Math.Pow(2.0, 3.0);
Question
Describe how nested method calls work. For example, if you have three nested method calls, which method executes first and how are return values propagated? Is there a limit to how many method calls can be nested?
Question
If a method does not return a value, its return type is ____________________.
Question
A(n) ____________________ is an encapsulated series of statements that carry out a task.
Question
A method ____________________ is a block of statements that carry out the method's work.
Question
If you create a Click() method that responds to button clicks, it will be ____ by default because it is associated with an object that is a Form .

A) local
B) static
C) qualified
D) nonstatic
Question
A method ____________________ defines the rules for using the method and can include accessibility, static, and return type modifiers.
Question
A ____ statement causes a value to be sent back to the calling method.

A) break
B) result
C) return
D) continue
Question
When you place a Button named okButton on a Form in the IDE and double-click it, a method is automatically generated with the following header: ____ okButton_Click( object sender, EventArgs e) .

A) public void
B) private void
C) static void
D) private int
Question
When method calls are placed inside other method calls, the calls are ____ method calls.

A) nested
B) interleaved
C) cascaded
D) children
Question
Write a DisplaySalesTax() method that receives the sales amount and tax rate as double s, and calculates and displays the sales tax. The method does not return a value.
Question
When an array passed to a method is passed by ____, the method receives the actual memory address of the array and has access to the actual values in the array elements.

A) reference
B) value
C) output
D) input
Question
For a method that accepts a parameter, what are the components of the parameter definition that must be included in the method declaration? Show an example of a method declaration with a parameter.
Question
What are the two most common accessibility levels in C#?
Question
Explain how to write a Main() method that accepts parameters. Why might this format be used?
Question
When writing an event-handling method in a GUI application, what should you consider about a variable's scope?
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/42
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 7: Using Methods
1
With ____, if a programmer changes the way in which a method internally works, programs that use that method will not be affected and will not need to be modified.

A) overloading
B) implementation hiding
C) polymorphism
D) inheritance
B
2
Because the ReadLine() method call can be assigned to a string, its return type is ____ .

A) int
B) Object
C) bool
D) string
D
3
The type of an argument in a method call must exactly match the type of the corresponding parameter specified in the method declaration.
False
4
If you use the keyword modifier ____, you indicate that a method can be called by referring to the class rather than an object from the class.

A) static
B) internal
C) protected
D) nonstatic
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
5
A method ____ is a variable that holds data passed to the method when it is called; it receives an argument's value when the method executes.

A) element
B) parameter
C) literal
D) declaration
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
6
The ____ accessibility modifier allows access to a method from other classes.

A) public
B) protected
C) private
D) protected internal
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
7
A program element's ____ is the segment of code in which it can be used.

A) scope
B) locality
C) accessibility
D) nesting
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
8
A declaration for a method that receives two or more arguments must list the type for each parameter separately only if the parameters have different types.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
9
A parameter within a method header is called a(n) ____ parameter.

A) formal
B) local
C) global
D) actual
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
10
A method can return, at most, one value to a method that calls it.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
11
To more easily incorporate methods into a program, it is common practice to store methods in their own classes and files. Then you can add them into any application that uses them. The resulting compound program is called a(n) ____.

A) interface
B) multifile assembly
C) hid assembly
D) hid implementation
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
12
A(n) ____ is a device you can use without knowing how it works internally.

A) white box
B) interface
C) black box
D) method
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
13
Methods can ____, or call, other methods; that is, a program uses a method's name and the method performs a job for the class.

A) instantiate
B) overload
C) inherit
D) invoke
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
14
The ____ accessibility modifier limits method access to the class that contains the method.

A) protected
B) private
C) protected internal
D) internal
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
15
If you do not provide an accessibility modifier for a method, it is private by default.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
16
A method that uses another is called a ____ of the method it uses.

A) peer
B) server
C) pair
D) client
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
17
The number of arguments does not need to match the number in the parameter list when you use ____.

A) default arguments
B) value parameters
C) scope relaxation
D) non-critical parameters
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
18
Arrays, like all objects, are passed by value.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
19
The optional declared ____ for a method (for example, public ) sets limits as to how other methods can use it.

A) protection
B) qualifier
C) accessibility
D) type
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
20
A formal parameter that receives a copy of the value passed to it is also an example of a(n) ____ parameter.

A) reference
B) output
C) input
D) value
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
21
What are the components of a C# method declaration?
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
22
Match between columns
Receives a copy of the value passed to it
parameter list
Receives a copy of the value passed to it
fully qualified name
Receives a copy of the value passed to it
value parameter
Receives a copy of the value passed to it
nonstatic method
Receives a copy of the value passed to it
local variable
Receives a copy of the value passed to it
calling method
Receives a copy of the value passed to it
field
Receives a copy of the value passed to it
bool
Receives a copy of the value passed to it
object's starting memory address
Optionally present within parentheses after the method name in a method declaration
parameter list
Optionally present within parentheses after the method name in a method declaration
fully qualified name
Optionally present within parentheses after the method name in a method declaration
value parameter
Optionally present within parentheses after the method name in a method declaration
nonstatic method
Optionally present within parentheses after the method name in a method declaration
local variable
Optionally present within parentheses after the method name in a method declaration
calling method
Optionally present within parentheses after the method name in a method declaration
field
Optionally present within parentheses after the method name in a method declaration
bool
Optionally present within parentheses after the method name in a method declaration
object's starting memory address
Can only be used in conjunction with an object
parameter list
Can only be used in conjunction with an object
fully qualified name
Can only be used in conjunction with an object
value parameter
Can only be used in conjunction with an object
nonstatic method
Can only be used in conjunction with an object
local variable
Can only be used in conjunction with an object
calling method
Can only be used in conjunction with an object
field
Can only be used in conjunction with an object
bool
Can only be used in conjunction with an object
object's starting memory address
One that calls another method
parameter list
One that calls another method
fully qualified name
One that calls another method
value parameter
One that calls another method
nonstatic method
One that calls another method
local variable
One that calls another method
calling method
One that calls another method
field
One that calls another method
bool
One that calls another method
object's starting memory address
A method's complete name including its class
parameter list
A method's complete name including its class
fully qualified name
A method's complete name including its class
value parameter
A method's complete name including its class
nonstatic method
A method's complete name including its class
local variable
A method's complete name including its class
calling method
A method's complete name including its class
field
A method's complete name including its class
bool
A method's complete name including its class
object's starting memory address
The return type for a method that returns either true or false
parameter list
The return type for a method that returns either true or false
fully qualified name
The return type for a method that returns either true or false
value parameter
The return type for a method that returns either true or false
nonstatic method
The return type for a method that returns either true or false
local variable
The return type for a method that returns either true or false
calling method
The return type for a method that returns either true or false
field
The return type for a method that returns either true or false
bool
The return type for a method that returns either true or false
object's starting memory address
What is received by an invoked method when an object is passed to it by reference
parameter list
What is received by an invoked method when an object is passed to it by reference
fully qualified name
What is received by an invoked method when an object is passed to it by reference
value parameter
What is received by an invoked method when an object is passed to it by reference
nonstatic method
What is received by an invoked method when an object is passed to it by reference
local variable
What is received by an invoked method when an object is passed to it by reference
calling method
What is received by an invoked method when an object is passed to it by reference
field
What is received by an invoked method when an object is passed to it by reference
bool
What is received by an invoked method when an object is passed to it by reference
object's starting memory address
This kind of variable is declared within a method and is not known to other methods
parameter list
This kind of variable is declared within a method and is not known to other methods
fully qualified name
This kind of variable is declared within a method and is not known to other methods
value parameter
This kind of variable is declared within a method and is not known to other methods
nonstatic method
This kind of variable is declared within a method and is not known to other methods
local variable
This kind of variable is declared within a method and is not known to other methods
calling method
This kind of variable is declared within a method and is not known to other methods
field
This kind of variable is declared within a method and is not known to other methods
bool
This kind of variable is declared within a method and is not known to other methods
object's starting memory address
A variable declared within a class but outside of the class's methods
parameter list
A variable declared within a class but outside of the class's methods
fully qualified name
A variable declared within a class but outside of the class's methods
value parameter
A variable declared within a class but outside of the class's methods
nonstatic method
A variable declared within a class but outside of the class's methods
local variable
A variable declared within a class but outside of the class's methods
calling method
A variable declared within a class but outside of the class's methods
field
A variable declared within a class but outside of the class's methods
bool
A variable declared within a class but outside of the class's methods
object's starting memory address
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
23
What are the components of a C# method?
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
24
Every method has a(n) ____________________, indicating what kind of value the method will return to any other method that calls it.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
25
You indicate that a method parameter is an array by placing ____ after the data type in the method's parameter list.

A) ()
B) $
C) []
D) {}
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
26
The keyword static is used with Main() methods in console applications because the method is associated with its containing class and not with an object. Why are Form methods, such as a Click() method that responds to button clicks, nonstatic?
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
27
You can tell a lot about a built-in method when you see how it is used. What can you tell about the built-in Pow() method (used to raise a number to a power) from the following statement?
double result = Math.Pow(2.0, 3.0);
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
28
Describe how nested method calls work. For example, if you have three nested method calls, which method executes first and how are return values propagated? Is there a limit to how many method calls can be nested?
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
29
If a method does not return a value, its return type is ____________________.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
30
A(n) ____________________ is an encapsulated series of statements that carry out a task.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
31
A method ____________________ is a block of statements that carry out the method's work.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
32
If you create a Click() method that responds to button clicks, it will be ____ by default because it is associated with an object that is a Form .

A) local
B) static
C) qualified
D) nonstatic
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
33
A method ____________________ defines the rules for using the method and can include accessibility, static, and return type modifiers.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
34
A ____ statement causes a value to be sent back to the calling method.

A) break
B) result
C) return
D) continue
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
35
When you place a Button named okButton on a Form in the IDE and double-click it, a method is automatically generated with the following header: ____ okButton_Click( object sender, EventArgs e) .

A) public void
B) private void
C) static void
D) private int
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
36
When method calls are placed inside other method calls, the calls are ____ method calls.

A) nested
B) interleaved
C) cascaded
D) children
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
37
Write a DisplaySalesTax() method that receives the sales amount and tax rate as double s, and calculates and displays the sales tax. The method does not return a value.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
38
When an array passed to a method is passed by ____, the method receives the actual memory address of the array and has access to the actual values in the array elements.

A) reference
B) value
C) output
D) input
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
39
For a method that accepts a parameter, what are the components of the parameter definition that must be included in the method declaration? Show an example of a method declaration with a parameter.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
40
What are the two most common accessibility levels in C#?
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
41
Explain how to write a Main() method that accepts parameters. Why might this format be used?
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
42
When writing an event-handling method in a GUI application, what should you consider about a variable's scope?
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 42 flashcards in this deck.