Chapter 8

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Assume you declare a variable as int x = 100; and correctly pass it to a method with the declaration private 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. The program will not run.

a

Assume you have declared a method as follows: private 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

Assume you declare a variable as int x = 100; and correctly pass it to a method with the declaration private 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

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

b

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

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

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

b

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

b

. 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

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

Assume you have declared a method as follows: private 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

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

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

c

Which of the following is a 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

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

d

Assume you have declared a method as follows: private 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

Assume you have declared a method with the following header: private 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

Suppose you have declared an integer array named scores, and you make the following method call: TotalScores(scores, num : 1); Of the following overloaded method definitions, which would execute? a. private static void TotalScores(int[] scores) b. private static void TotalScores(int[] scores, int num) c. private static void TotalScores(int[] scores, int num = 10, int code = 10) d. The program would not compile.

d

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

d

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

d


Kaugnay na mga set ng pag-aaral

Live Virtual Machine Lab 3.3: Module 03 Identifying Different Application Exploits

View Set

Lecture 3- Attention and Performance

View Set

chapter 18 the digestive system assignment human physiology

View Set

chapter 8 section 8.1 measurement of pulmonary function

View Set

Chapter 9: Food & Supplement Labeling

View Set

Colligative Properties and Osmotic Pressure

View Set