Intro to C# Unit 7

  1. At most, a class can contain ____ method(s).




    D. any number of
  2. Which of the following is a good reason for creating methods within a program?




    D. Methods are easily reusable.
  3. In C#, a method must include all of the following except _______.




    A. an access modifier
  4. If a method does not contain a declared accessibility, then the method is ____.




    B. private
  5. Every method declaration must contain _____.




    A. a return type
  6. 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
  7. If you use the keyword modifier static in a method header, you indicated that the method _____.




    D. is called without an object reference
  8. A method's type is also its ____.




    B. return type
  9. When you use a method, you do not need to know how it operates internally. This feature is called ______.




    B. implementation hiding
  10. 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
  11. 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);
  12. 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
  13. In the method call PrintTheData(double salary); salary is the ___ parameter.




    D. actual
  14. A program contain the method call PrintTheData(salary);. In the method definition, the name of the formal parameter must be ____.




    B. any legal identifier
  15. 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)
  16. 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.
  17. 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);
  18. 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.
  19. 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.
  20. 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 _______.




    C. reference
Author
jdavis123
ID
358369
Card Set
Intro to C# Unit 7
Description
Updated