Deck 6: 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
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/76
Play
Full screen (f)
Deck 6: Methods
1
Which of the following is not a way of packaging code?
A)methods
B)classes
C)variables
D)class libraries
A)methods
B)classes
C)variables
D)class libraries
C
2
Methods can return at most one value.
True
3
A function can return multiple values.
False
4
Two types of methods exist: subroutines and functions.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
5
A method must always return a result to the method's caller.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
6
Many classes and methods for performing common operations such as mathematical calculations and string manipulations are already provided by .NET's Framework Class Library.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
7
The header for a function must define the return type of the value to be returned.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
8
Methods are called by writing the name of the method followed by enclosed in parentheses.
A)a condition
B)arguments
C)a counter
D)None of the above.
A)a condition
B)arguments
C)a counter
D)None of the above.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
9
A method is invoked by a .
A)return statement
B)method header
C)method call
D)None of the above.
A)return statement
B)method header
C)method call
D)None of the above.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
10
Repeating high-quality,high-performance code in a program helps ensure higher quality programs.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
11
Which of the following is not part of the method header?
A)method body
B)method name
C)parameter list
D)None of the above
A)method body
B)method name
C)parameter list
D)None of the above
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
12
What do functions have that subroutines do not?
A)Exit Sub keywords
B)a return value
C)ByVal keyword
D)None of the above
A)Exit Sub keywords
B)a return value
C)ByVal keyword
D)None of the above
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
13
Subroutines are _______.
A)methods that can be called only once
B)methods that cannot be called with arguments
C)methods that do not return a value
D)methods that return an optional value
A)methods that can be called only once
B)methods that cannot be called with arguments
C)methods that do not return a value
D)methods that return an optional value
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
14
It's best to have each method complete as many tasks as possible.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
15
The return type of a method's return value is specified in the method call.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
16
Information may be methods.
A)provided for
B)returned from
C)manipulated in
D)All of the above.
A)provided for
B)returned from
C)manipulated in
D)All of the above.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
17
Which of the following is not a motivation for dividing code into methods?
A)makes program development more manageable
B)software reusability
C)have more separate files
D)avoid repeating code
A)makes program development more manageable
B)software reusability
C)have more separate files
D)avoid repeating code
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
18
Method arguments can be constants,variables or more involved expressions.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
19
It's possible for _________ methods to be called without the need for an object of the class to exist.
A)Special
B)Independent
C)Shared
D)Dependent
A)Special
B)Independent
C)Shared
D)Dependent
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
20
The Return statement must occur at the end of a method for it to operate correctly.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
21
When Option Explicit is set to Off,the compiler will interpret misspelled variable names as new variables.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
22
Type-conversion functions are used to perform explicit conversions between data types.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
23
The methods in the Convert class can be used for explicit and narrowing conversions.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
24
Keyword Val is used to pass an argument by value.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
25
A __________ conversion occurs when there is potential for data loss during the conversion.
A)widening
B)implicit
C)narrowing
D)explicit
A)widening
B)implicit
C)narrowing
D)explicit
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
26
Passing an argument to a method by value provides the method with:
A)the address of the value in memory
B)a separate copy of the value
C)the type of the value
D)None of the above.
A)the address of the value in memory
B)a separate copy of the value
C)the type of the value
D)None of the above.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
27
Which of the following statements describes block scope?
A)It begins at the beginning of the class declaration and terminates at the closing End Class.
B)It limits label scope to only the method in which it is declared.
C)It begins at the identifier's declaration and ends at the terminating End clause.
D)It is valid for one statement only.
A)It begins at the beginning of the class declaration and terminates at the closing End Class.
B)It limits label scope to only the method in which it is declared.
C)It begins at the identifier's declaration and ends at the terminating End clause.
D)It is valid for one statement only.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
28
__________ argument conversion converts an argument's value to the type that a method expects to receive in its corresponding parameter.
A)Widening
B)Implicit
C)Narrowing
D)Explicit
A)Widening
B)Implicit
C)Narrowing
D)Explicit
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
29
__________ forces you to declare all variables before they're used in a program.
A)Option Explicit
B)Option Strict
C)Option Convert
D)None of the above.
A)Option Explicit
B)Option Strict
C)Option Convert
D)None of the above.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
30
Which of these statements best defines scope?
A)Scope refers to the classes that have access to a variable.
B)Scope determines whether a variable's value can be altered.
C)Scoping allows you to use a class without using its fully qualified name.
D)Scope is the portion of a program that can refer to an entity by its simple name.
A)Scope refers to the classes that have access to a variable.
B)Scope determines whether a variable's value can be altered.
C)Scoping allows you to use a class without using its fully qualified name.
D)Scope is the portion of a program that can refer to an entity by its simple name.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
31
If a local variable in a method has the same name as a variable in the main program,what will occur?
A)an error is generated
B)the variable in the main program is "hidden" until the method is finished executing
C)the variable in the main program will override the variable from the method
D)None of the above.
A)an error is generated
B)the variable in the main program is "hidden" until the method is finished executing
C)the variable in the main program will override the variable from the method
D)None of the above.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
32
Option Strict is meant to reduce the chance of errors by disabling narrowing conversions.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
33
Passing arguments by reference can weaken security because the called method can modify the caller's data.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
34
__________ causes the compiler to check all conversions and requires you to perform all narrowing conversions explicitly.
A)Option Explicit
B)Option Strict
C)Option Convert
D)None of the above
A)Option Explicit
B)Option Strict
C)Option Convert
D)None of the above
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
35
Which statement is false?
A)To ensure that the operands are of the same type,Visual Basic performs implicit conversion on selected operands.
B)Cast operators are unary operators.
C)Cast operations are performed implicitly when Option Strict is off.
D)Cast operators are formed by placing parentheses around the name of a type.
A)To ensure that the operands are of the same type,Visual Basic performs implicit conversion on selected operands.
B)Cast operators are unary operators.
C)Cast operations are performed implicitly when Option Strict is off.
D)Cast operators are formed by placing parentheses around the name of a type.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
36
The keyword is used to pass value-type variables to methods by reference.
A)ByRef
B)Reference
C)RefPass
D)Ref
A)ByRef
B)Reference
C)RefPass
D)Ref
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
37
Any variables declared in a For…Next statement header have block scope within that statement.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
38
Identifiers declared within a class have .
A)block scope
B)class scope
C)local scope
D)module scope
A)block scope
B)class scope
C)local scope
D)module scope
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
39
A __________ conversion occurs when an argument is converted to a parameter of another type that can hold more data.
A)widening
B)implicit
C)narrowing
D)explicit
A)widening
B)implicit
C)narrowing
D)explicit
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
40
A method's changes to a variable that is passed by value do not affect the value of the original variable.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
41
Cast operations are formed by enclosing a type name in braces.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
42
The expression value = 2 + randomObject.Next(8)will result in a random number in what range?
A)0 through 8
B)2 through 9
C)2 through 10
D)2 through 8
A)0 through 8
B)2 through 9
C)2 through 10
D)2 through 8
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
43
Values produced by random-number generating methods are truly random.There is no way to predict the next result.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
44
If values generated by a random number generator are truly random,the
frequencies of each of the values will be approximately the same.
frequencies of each of the values will be approximately the same.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
45
A is provided to a random number generator to ensure the same sequence of numbers is not generated during each execution.
A)date value
B)parameter
C)seed value
D)None of the above.
A)date value
B)parameter
C)seed value
D)None of the above.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
46
A(n)___________is a value type that contains a set of constant values.
A)enumeration
B)object
C)set
D)None of the above.
A)enumeration
B)object
C)set
D)None of the above.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
47
If a change is made to an enumeration,you must change the program in every place that the old value was used.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
48
Variables declared in a method exist while the method is active and are destroyed when the method is exited.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
49
When a single argument is passed to Next,that argument is the:
A)collection factor
B)range factor
C)random factor
D)scaling factor
A)collection factor
B)range factor
C)random factor
D)scaling factor
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
50
Values returned by the Random class method Next are pseudo-random numbers.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
51
A variable declared in a class cannot have the same name as a variable declared in another class.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
52
A GroupBox is used to group related code.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
53
The values produced by Random are weighted so that some values will be generated with greater frequency than others.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
54
The Next method produces a random number from zero up to and including the number it is provided by the programmer.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
55
Which of the following cannot be an Enum's underlying type?
A)SByte
B)Integer
C)ULong
D)Double
A)SByte
B)Integer
C)ULong
D)Double
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
56
A button will become unavailable only if an error is detected in the event handler for that button.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
57
Random-number generator scaling is the process of:
A)causing each number in a range to have equal likelihood of being generated
B)modifying the range from which a number will be generated
C)calculating a sequence of numbers to be generated
D)None of the above.
A)causing each number in a range to have equal likelihood of being generated
B)modifying the range from which a number will be generated
C)calculating a sequence of numbers to be generated
D)None of the above.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
58
A particular seed value always produces the same series of random numbers.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
59
A GroupBox's Text property displays in the upper-left corner of the GroupBox.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
60
A reference-type variable can be specified as not being associated with an object by using the keyword Nothing.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
61
Which of the following method headers are appropriate for the method call SR(True,0,2.6)?
A)Sub SR( ByVal a As Boolean,ByRef b As Double,_ ByRef c As Integer )
B)Sub SR( ByVal a As Boolean,ByVal b As Double,_ ByVal c As Double )
C)Sub SR(ByRef a As Boolean,ByRef b As Integer,_ By Ref c As Double )
D)b and c
A)Sub SR( ByVal a As Boolean,ByRef b As Double,_ ByRef c As Integer )
B)Sub SR( ByVal a As Boolean,ByVal b As Double,_ ByVal c As Double )
C)Sub SR(ByRef a As Boolean,ByRef b As Integer,_ By Ref c As Double )
D)b and c
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
62
Which of the following will violate the rules of overloading methods?
A)Methods with the same signatures but different return types.
B)Methods with different signatures but the same return type.
C)Methods with different number of arguments.
D)Method with different types of arguments.
A)Methods with the same signatures but different return types.
B)Methods with different signatures but the same return type.
C)Methods with different number of arguments.
D)Method with different types of arguments.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
63
Optional arguments can be placed in any particular order with non-Optional arguments in a method header.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
64
Declaring a non-Optional parameter to the right of an Optional parameter is allowed.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
65
The Step Into debugger command can be used to __________.
A)return from the method to the caller
B)modify the code at execution time to correct a logic error
C)execute the code statements in a different order to locate a bug
D)view the code for a called method as it executes
A)return from the method to the caller
B)modify the code at execution time to correct a logic error
C)execute the code statements in a different order to locate a bug
D)view the code for a called method as it executes
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
66
Which of the following method calls would not be valid with the following method header?
A)Example()
B)Example(True)
C)Example(False,10)
D)None of the above

A)Example()
B)Example(True)
C)Example(False,10)
D)None of the above
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
67
If you wish to execute several statements without repeatedly clicking the Step Over debugger command,you can right click the statement where you'd like to continue step-by-step execution,then select Run to Cursor from the menu that appears.The debugger will execute the statements up to,and including,that statement.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
68
Which of the following statements is false?
A)To have an optional parameter,place the Optional keyword at the beginning of an argument in the method header.
B)The optional parameter must provide a default value.
C)The optional argument(s)can be placed anywhere in the parameter list of the method header.
D)When calling a method,the optional argument can be omitted.
A)To have an optional parameter,place the Optional keyword at the beginning of an argument in the method header.
B)The optional parameter must provide a default value.
C)The optional argument(s)can be placed anywhere in the parameter list of the method header.
D)When calling a method,the optional argument can be omitted.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
69
Overloaded methods always have the same _________.
A)method name
B)return type
C)number of the parameters
D)order of the parameters
A)method name
B)return type
C)number of the parameters
D)order of the parameters
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
70
An overloaded method is one that
A)has a different name than another method,but the same parameters.
B)has the same name as another method,but different parameters.
C)has the same name and parameters as a method defined in another class.
D)has the same name and parameters as another method,but a different return type.
A)has a different name than another method,but the same parameters.
B)has the same name as another method,but different parameters.
C)has the same name and parameters as a method defined in another class.
D)has the same name and parameters as another method,but a different return type.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
71
Overloaded methods normally perform similar tasks,but on different types of data.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
72
The Step Out debugger command can be used to __________.
A)return from the method to the caller
B)modify the code at execution time to correct a logic error
C)execute the code statements in a different order to locate a bug
D)view the code for a called method as it executes
A)return from the method to the caller
B)modify the code at execution time to correct a logic error
C)execute the code statements in a different order to locate a bug
D)view the code for a called method as it executes
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
73
When an app is running in the debugger,the Start Debugging command becomes the Continue command.If you click Continue while in break mode,the debugger will execute statements until it reaches the next breakpoint.If there aren't any,the program will simply execute until it completes or until the event handler that you're debugging finishes executing.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
74
Every argument specified in a method header must be provided in a method call.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
75
If the next statement to execute is not a method call,then the Step Into debugger command has the same effect as the Step Over command.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
76
You must provide a default value for any arguments that are declared Optional.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck