Chapter 8

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

6. Assume you declare a variable as int x = 100; and correctly pass it to a method with the declaration public static void IncreaseValue(int x). There is a single statement within the IncreaseValue() method: x = x + 25;. Back in the Main() method, after the method call, what is the value of x? a. 100 b. 125 c. It is impossible to tell. d. Th e program will not run.

100

8. A parameter array. a. is declared using the keyword params b. can accept any number of arguments of the same data type c. Both of these are true. d. None of these are true.

c. Both of these are true

18. Assume you have declared a method as follows: public static double CalculateDiscount(int acct = 0, double price = 0, double discount = 0) Which of the following is a legal method call? a. CalculateDiscount(); . b. CalculateDiscount(200.00); c. CalculateDiscount(3000.00. 0.02); d. None of the above are legal.

a. CalculateDiscount();

5. Assume you declare a variable as int x = 100; and correctly pass it to a method with the declaration public static void IncreaseValue(ref int x). There is a single statement within the IncreaseValue() method: x = x + 25;. Back in the Main() method, after the method call, what is the value of x? a. 100 b. 125. c. It is impossible to tell. d. The program will not run.

b. 125

4. When you declare a value parameter, you precede its name with . a. nothing b. a data type. c. the keyword val and a data type d. the keyword ref and its data type

b. a data type

15. When one of a method's parameters is optional, it means that . a. no arguments are required in a call to the method b. a default value will be assigned to the parameter if no argument is sent for it . c. a default value will override any argument value sent to it d. you are not required to use the parameter within the method body

b. a default value will be assigned to the parameter if no argument is sent for it

3. Which type of method parameter receives the address of the variable passed in? a. a value parameter b. a reference parameter c. an output parameter d. two of the above

b. a reference parameter

10. Correctly overloaded methods must have the same. a. return type b. identifier. c. parameter list d. All of the above.

b. identifier

16. Which of the following is an illegal method declaration? a. public static void CreateStatement(int acctNum, double balance = 0.0) b. public static void CreateStatement(int acctNum = 0, double balance) . c. public static void CreateStatement(int acctNum = 0, balance = 0) d. All of these are legal.

b. public static void CreateStatement(int acctNum = 0, double balance)

13. Which of the following pairs of method declarations represent correctly overloaded methods? a. public static void Method(int a) public static void Method(int b) b. public static void Method(double d) public static int Method() . c. public static double Method(int e) public static int Method(int f) d. Two of these are correctly overloaded methods.

b. public static void Method(double d) public static int Method()

7. What is the difference between a reference parameter and an output parameter? a. A reference parameter receives a memory address; an output parameter does not. b. A reference parameter occupies a unique memory address; an output parameter does not. c. A reference parameter must have an initial value; an output parameter need not. d. A reference parameter need not have an initial value; an output parameter must.

c. A reference parameter must have an initial value; an output parameter need not

17. Assume you have declared a method as follows: public static double ComputeBill(int acct, double price, double discount = 0) Which of the following is a legal method call? a. ComputeBill(); b. ComputeBill(1001); c. ComputeBill(1001, 200.00); . d. None of the above are legal.

c. ComputeBill(1001, 200.00);

11. Methods are ambiguous when they . a. are overloaded b. are written in a confusing manner c. are indistinguishable to the compiler. d. have the same parameter type as their return type

c. are indistinguishable to the compiler

2. Which is not a type of method parameter in C#? a. value b. reference c. forensic d. output

c. forensic

1. A mandatory parameter . a. is any argument sent to a method b. is preceded by the keyword man c. requires an argument to be sent from a method call. d. All of the above are true.

c. requires an argument to be sent from a method call

9. Assume you have declared a method with the following header: public static void DisplayScores(params int[] scores) Which of the following method calls is valid? a. DisplayScores(20); b. DisplayScores(20, 33); c. DisplayScores(20, 30, 90); d. All of the above are valid.

d. All of the above are valid

19. Assume you have declared a method as follows: public static double DisplayData(string name = "XX", double amount = 10.0) Which of the following is an illegal method call? a. DisplayData(name : "Albert"); b. DisplayData(amount : 200, name : "Albert"); c. DisplayData(amount : 900.00); d. All of these are legal.

d. All of these are legal

12. Which of the following pairs of method declarations represent correctly overloaded methods? a. public static void MethodA(int a) public static void MethodA(int b, double c) b. public static void MethodB(double d) public static void MethodB() c. public static double MethodC(int e) public static double MethodD(int f) d. Two of these are correctly overloaded methods.

d. Two of these are correctly overloaded methods

14. The process of determining which overloaded version of a method to execute is overload ____________. a. confusion b. infusion c. revolution d. resolution .

d. resolution


संबंधित स्टडी सेट्स

Federal Income Tax 3325 Chapter 6 Homework

View Set

Safety & Quality Improvements Part 1

View Set

Nutrition and Elimination Module

View Set

Human Biology: Reproductive System

View Set

Biology Test 8: Denaturation and Renaturation of Proteins

View Set