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
Match between columns
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/42
Play
Full screen (f)
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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) {}
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);
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
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
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
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
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
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