C# Programming Exam: Trivia Quiz!

40 Questions | Total Attempts: 202

SettingsSettingsSettings
Please wait...
C# Programming Exam: Trivia Quiz!

.


Questions and Answers
  • 1. 
    At most, a class can contain ____________ method(s).
    • A. 

      0

    • B. 

      1

    • C. 

      2

    • D. 

      Any number of

  • 2. 
    What is the most important reason for creating methods within a program?
    • A. 

      Methods are easily reusable.

    • B. 

      Because all methods must be stored in the same class, they are easy to find

    • C. 

      The Main() method becomes more detailed.

    • D. 

      All of these are true.

  • 3. 
    In C#, a method must include all of the following except a ___________ .
    • A. 

      Return type

    • B. 

      Parameter list

    • C. 

      Body

    • D. 

      Closing brace

  • 4. 
    A method declaration might contain ____________ .
    • A. 

      Declared accessibility

    • B. 

      A nonstatic modifier

    • C. 

      Multiple return types

    • D. 

      Parameters separated by dots

  • 5. 
    A method declaration must contain _______________ .
    • A. 

      A statement of purpose

    • B. 

      Declared accessibility

    • C. 

      The static modifier

    • D. 

      A return type (even void) a return type (even void)

  • 6. 
    If you want to create a method that other methods can access without limitations, you declare the method to be _____________.
    • A. 

      Unlimited

    • B. 

      Static or static public

    • C. 

      Shared

    • D. 

      Unrestricted

  • 7. 
    If you use the keyword modifier static in a method header, you indicate that the method ______________.
    • A. 

      Can be called without referring to an object or class

    • B. 

      Cannot be copied

    • C. 

      Can be called only once

    • D. 

      Cannot require parameters

  • 8. 
    A method’s type is also its ____________ .
    • A. 

      Accessibility

    • B. 

      Parameter type

    • C. 

      Return type

    • D. 

      Scope

  • 9. 
    When you use a method, you do not need to know how it operates internally. This feature is called _____________
    • A. 

      Scope management

    • B. 

      Selective ignorance

    • C. 

      Privacy

    • D. 

      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. 

      A pair of parentheses

    • B. 

      The type of the parameter

    • C. 

      A local name for the parameter

    • D. 

      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 declaration      static public void AMethod(int num)
    • A. 

      AMethod(int 55);

    • B. 

      AMethod(myAge);

    • C. 

      AMethod(int myAge);

    • D. 

      AMethod(int myAge);

  • 12. 
    Suppose you have declared a method static public void CalculatePay(double rate) When a method calls the CalculatePay() method, the calling method ______________ .
    • A. 

      Must contain a declared double named rate

    • B. 

      Might contain a declared double named rate

    • C. 

      Cannot contain a declared double named rate

    • D. 

      Cannot contain any declared double variables

  • 13. 
    In the method call      PrintTheData(double salary); salary is the ______________ parameter.
    • A. 

      Formal

    • B. 

      Actual

    • C. 

      Propsed

    • D. 

      Preferred

  • 14. 
    A program contains the method call     PrintTheData(salary);In the method declaration, the name of the formal parameter must be __________ .
    • A. 

      Salary

    • B. 

      Any legal identifier other than salary

    • C. 

      Any legal identifier

    • D. 

      Omitted

  • 15. 
    What is a correct declaration for a method that receives two double arguments and calculates the difference between them?
    • A. 

      Static public void CalcDifference(double price1, price2)

    • B. 

      Static public void CalcDifference(double price1, double price2)

    • C. 

      Both of these are correct.

    • D. 

      None of these are correct.

  • 16. 
    What is a correct declaration for a method that receives two double arguments and sums them?
    • A. 

      Static public void CalcSum(double firstValue, double secondValue)

    • B. 

      Static public void CalcSum(double price1, double price2)

    • C. 

      Both of these are correct.

    • D. 

      None of these are correct.

  • 17. 
    A method is declared as      public static double CalcPay(int hoursWorked) Suppose you write a Main() method in the same class that contains the declarations      int hours = 35; double pay; Which of the following represents a correct way to call the CalcPay() method from the Main() method?
    • A. 

      Hours = CalcPay();

    • B. 

      Hours = Main.CalcPay();

    • C. 

      Pay = CalcPay(hoursWorked);

    • D. 

      Pay = CalcPay(hours);

  • 18. 
    Suppose the value of boolean method: isRateOK() = true and the value of boolean method isQuantityOK() = false. When you evaluate the expression      (isRateOK() || isQuantityOK()), which of the following is true?
    • A. 

      Only the method isRateOK() executes.

    • B. 

      Only the method isQuantityOK() executes.

    • C. 

      Both methods execute.

    • D. 

      Neither method executes.

  • 19. 
    Suppose the value of boolean method isRateOK() = true and the value of boolean method isQuantityOK() = false. When you evaluate the expression      (isRateOK() && isQuantityOK()) which of the following is true?
    • A. 

      Only the method isRateOK() executes.

    • B. 

      Only the method isQuantityOK() executes.

    • C. 

      Both methods execute.

    • D. 

      Neither method 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 ___________
    • A. 

      Reference

    • B. 

      Value

    • C. 

      Alias

    • D. 

      Orientation

  • 21. 
    A structure that allows repeated execution of a block of statements is a(n) __________________ .
    • A. 

      Selection

    • B. 

      Loop

    • C. 

      Sequence

    • D. 

      Array

  • 22. 
    The body of a while loop can consist of ______________
    • A. 

      A single statement

    • B. 

      A block of statements within curly braces

    • C. 

      Either a or b

    • D. 

      Neither a nor b neither a nor b neither a nor b neither a nor b

  • 23. 
    A loop that never ends is called a(n) ___________ loop.
    • A. 

      While

    • B. 

      For

    • C. 

      Counted

    • D. 

      Infinite

  • 24. 
    Which of the following is not required of a loop control variable in a correctly working loop?
    • A. 

      It is initialized before the loop starts.

    • B. 

      It is tested.

    • C. 

      It is reset to its initial value before the loop ends.

    • D. 

      It is altered in the loop body.

  • 25. 
    while loop with an empty body contains no ___________
    • A. 

      Loop control variable

    • B. 

      Statements

    • C. 

      Curly braces

    • D. 

      Test within the parentheses of the while statement