Which of the following is a good reason for creating methods within a program?
D. Methods are easily reusable.
In C#, a method must include all of the following except _______.
A. an access modifier
If a method does not contain a declared accessibility, then the method is ____.
B. private
Every method declaration must contain _____.
A. a return type
If you want to create a method that other methods in other classes can access without limitations, you declare the method to be _____.
B. public
If you use the keyword modifier static in a method header, you indicated that the method _____.
D. is called without an object reference
A method's type is also its ____.
B. return type
When you use a method, you do not need to know how it operates internally. This feature is called ______.
B. implementation hiding
When you write the method declaration for a method that can receive a parameter, you need to include all of the following items except _______.
A. an initial value for the parameter
Suppose you have declared a variable as int myAge = 21;. Which of the following is a legal call to a method with the following declaration?
private static void AMethod(int num)
B. AMethod (myAge);
Suppose you have declared a method named private static void CalculatePay(double rate). When a method calls the CalculatePay() method, the calling method _____.
A. might contain a declared double named rate
In the method call PrintTheData(double salary); salary is the ___ parameter.
D. actual
A program contain the method call PrintTheData(salary);. In the method definition, the name of the formal parameter must be ____.
B. any legal identifier
What is a correct declaration for a method that receives two double arguments, calculates and displays the difference between them, and returns nothing?
A. private static void CalcDifference(double price1, double price2)
What is a correct declaration for a method that receives two double arguments and sums them but does not return anything?
C. Both of these are correct.
A method is declared as private static double CalcPay(int hoursWorked). Suppose you write a Main() method in the same class and that it contains the declarations int hours = 35; and double pay;. Which of the following represents a correct way to call the CalcPay() method from the Main() method?
C. pay = CalcPay(hours);
Suppose the value of isRateOK() is true, and the value of IsQuantityOK() is false. When you evaluate the expression IsRateOK() && IsQuantityOK(), which of the following is true?
A. Both methods execute.
Suppose the value of isRateOK() is true, and the value of IsQuantityOK() is false. When you evaluate the expression IsRateOK() || IsQuantityOK(), which of the following is true?
D. Only the method IsRateOK() executes.
When an array is passed to a method, the method has access to the array's memory address. This means an array is passed by _______.