Deck 7: Using 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
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/39
Play
Full screen (f)
Deck 7: Using Methods
1
What is a method that uses another method considered to be?
A) a method peer
B) a server method
C) a method pair
D) a client of the other method
A) a method peer
B) a server method
C) a method pair
D) a client of the other method
D
2
A formal parameter that receives a copy of the value passed to it is an example of what type of parameter?
A) reference
B) output
C) input
D) value
A) reference
B) output
C) input
D) value
D
3
A parameter within a method header that accepts a value is considered to be what type of parameter?
A) formal parameter
B) local parameter
C) global parameter
D) actual parameter
A) formal parameter
B) local parameter
C) global parameter
D) actual parameter
A
4
What keyword modifier indicates 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
A) static
B) internal
C) protected
D) nonstatic
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
5
What accessibility modifier limits method access to the class that contains the method?
A) protected
B) private
C) protected internal
D) internal
A) protected
B) private
C) protected internal
D) internal
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
6
What technique allows a programmer to change the way in which a method works internally without affecting programs that utilize the method?
A) overloading
B) implementation hiding
C) polymorphism
D) inheritance
A) overloading
B) implementation hiding
C) polymorphism
D) inheritance
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
7
When can a method be called with fewer arguments than exist in the parameter list for the method?
A) Only when default arguments are defined for the method.
B) Only when value parameters are passed by other parts of the program.
C) Only when scope relaxation is used to allow global variables.
D) Only when the parameters are marked as non-critical parameters.
A) Only when default arguments are defined for the method.
B) Only when value parameters are passed by other parts of the program.
C) Only when scope relaxation is used to allow global variables.
D) Only when the parameters are marked as non-critical parameters.
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
8
What is the return type of the ReadLine() method call?
A) int
B) Object
C) bool
D) string
A) int
B) Object
C) bool
D) string
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
9
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 39 flashcards in this deck.
Unlock Deck
k this deck
10
If you do not provide an accessibility modifier for a method, it is private by default.
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
11
The process of calling a method's name and using the method to perform a job for a class is also known by what term?
A) instantiating the method
B) overloading the method
C) inheriting the method
D) invoking the method
A) instantiating the method
B) overloading the method
C) inheriting the method
D) invoking the method
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
12
Arrays, like all objects, are passed by value.
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
13
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.What is the resulting compound program called?
A) a compound interface
B) a multifile assembly
C) a hid assembly
D) a hid implementation
A) a compound interface
B) a multifile assembly
C) a hid assembly
D) a hid implementation
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
14
Variables and constants that are declared within a method are only available until the end of the method.Why is this?
A) The method's variables exist within a scope, and are only visible within the method.
B) The variables utilize defined locality.
C) The variables are not configured for accessibility.
D) Variables do not support nesting in C#.
A) The method's variables exist within a scope, and are only visible within the method.
B) The variables utilize defined locality.
C) The variables are not configured for accessibility.
D) Variables do not support nesting in C#.
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
15
What accessibility modifier allows access to a method from other classes?
A) public
B) protected
C) private
D) protected internal
A) public
B) protected
C) private
D) protected internal
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
16
A method can return, at most, one value to a method that calls it.
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
17
What optionally declared method modifier can set limits as to how other methods are able to use the method?
A) protection
B) qualifier
C) accessibility
D) type
A) protection
B) qualifier
C) accessibility
D) type
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
18
What term is used to describe any device you can use without knowing how it works internally?
A) white box
B) interface
C) black box
D) method
A) white box
B) interface
C) black box
D) method
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
19
What is the name for a variable that holds data passed to a method when it is called?
A) element
B) parameter
C) literal
D) declaration
A) element
B) parameter
C) literal
D) declaration
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
20
The type of an argument in a method call must exactly match the type of the corresponding parameter specified in the method declaration.
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
21
Under what circumstances will a method receive the actual memory address of a passed array, and be able to alter values in the original array?
A) Only when it is passed by reference.
B) Only when it is passed by value.
C) Only when the array is inherited.
D) Only when the array is within the method's scope.
A) Only when it is passed by reference.
B) Only when it is passed by value.
C) Only when the array is inherited.
D) Only when the array is within the method's scope.
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
22
What are the two most common accessibility levels in C#?
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
23
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 39 flashcards in this deck.
Unlock Deck
k this deck
24
When a method resides entirely within another method, and can only be called from within the containing method, what is the method known as?
A) It is a local function.
B) It is a client function.
C) It is a parent function.
D) It is a scope function.
A) It is a local function.
B) It is a client function.
C) It is a parent function.
D) It is a scope function.
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
25
Write a DisplaySalesTax() method that receives the sales amount and tax rate as doubles, and calculates and displays the sales tax.The method does not return a value.
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
26
When a variable or constant is required by multiple methods in a GUI program, where should it be defined?
A) Inside one of the methods used by the GUI.
B) Inside a nested method shared by both methods.
C) Outside of the methods, but inside of the Form class shared by both methods.
D) Inside of an inherited class.
A) Inside one of the methods used by the GUI.
B) Inside a nested method shared by both methods.
C) Outside of the methods, but inside of the Form class shared by both methods.
D) Inside of an inherited class.
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
27
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 39 flashcards in this deck.
Unlock Deck
k this deck
28
If no method access specifier is defined for Main(), what will it be by default?
A) public
B) static
C) private
D) inherited
A) public
B) static
C) private
D) inherited
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
29
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 39 flashcards in this deck.
Unlock Deck
k this deck
30
What are the components of a C# method declaration?
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
31
When you place a button named okButton on a Form in the IDE and double-click it, what method header is generated automatically? (Note that if you are using Visual Studio 2019, each method name will start with an uppercase letter.)
A) public void okButton_Click(object sender, EventArgs e)
B) private void okButton_Click(object sender, EventArgs e)
C) static void okButton_Click(object sender, EventArgs e)
D) private int okButton_Click(object sender, EventArgs e)
A) public void okButton_Click(object sender, EventArgs e)
B) private void okButton_Click(object sender, EventArgs e)
C) static void okButton_Click(object sender, EventArgs e)
D) private int okButton_Click(object sender, EventArgs e)
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
32
What characters are placed after the data type in a method's parameter list to indicate that a method parameter is an array?
A) ()
B) <>
C) []
D) {}
A) ()
B) <>
C) []
D) {}
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
33
What statement is used to cause a value to be sent back to the calling method?
A) break
B) result
C) return
D) continue
A) break
B) result
C) return
D) continue
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
34
What are the components of a C# method?
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
35
Explain how to write a Main() method that accepts parameters.Why might this format be used?
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
36
How are the parameters for a Click() method received?
A) The method must be called manually by another method.
B) The method must be passed the parameters by reference.
C) The method receives the parameters automatically when the corresponding Button is pressed.
D) The method does not accept any parameters.
A) The method must be called manually by another method.
B) The method must be passed the parameters by reference.
C) The method receives the parameters automatically when the corresponding Button is pressed.
D) The method does not accept any parameters.
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
37
What is the term used to describe the calling of a method from within another method?
A) nested method calling
B) interleaved method calling
C) method cascading
D) method children
A) nested method calling
B) interleaved method calling
C) method cascading
D) method children
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
38
What will a Click() method that responds to button clicks be by default, due to the fact that it is associated with an object that is a Form?
A) local
B) static
C) qualified
D) nonstatic
A) local
B) static
C) qualified
D) nonstatic
Unlock Deck
Unlock for access to all 39 flashcards in this deck.
Unlock Deck
k this deck
39
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 39 flashcards in this deck.
Unlock Deck
k this deck