chapter 14

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

To add a method to a delegate, you can use the ________. Selected Answer: [None Given]Answers:Add function Plus function += operator + operator

+=

Which of the following is the lambda operator? Selected Answer: [None Given]Answers:>= =+ += =>

=>

Given the following delegate type declaration, which statement creates a delegate of the Expon type that references a method that returns the cube of a variable, num?delegate int Expon(int num); Selected Answer: [None Given]Answers: Expon Cube => num * num * num; int Cube = num => num * num * num; Expon int Cube => num = num * num * num; Expon Cube = num => num * num * num;

Expon Cube = num => num * num * num;

.NET provides all the delegate types you will ever need. Selected Answer: [None Given] Answers: True False

F

A delegate can only reference one method. Selected Answer: [None Given] Answers: True False

F

Because a delegate refers to a method, it cannot be passed as an argument to a method. Selected Answer: [None Given] Answers: True False

F

If a delegate type specifies multiple parameters, you cannot use a lambda expression with that delegate because lambda expressions can only have one parameter. Selected Answer: [None Given] Answers: True False

F

If a delegate type specifies no parameters, you cannot use a lambda expression with that delegate because lambda expressions must have one parameter. Selected Answer: [None Given] Answers: True False

F

In the following code, the name of the delegate is trip. func<int, double> triple = delegate(int trip){ return trip * 3;}; Selected Answer: [None Given] Answers: True False

F

Once a delegate has been created it can never be assigned to another method. Selected Answer: [None Given] Answers: True False

F

The .NET built-in Action delegate type invokes a method that accepts one argument and returns a boolean value. Selected Answer: [None Given] Answers: True False

F

The body of a lambda expression can only contain a single statement. Selected Answer: [None Given] Answers: True False

F

There are no List methods that will work with delegates. Selected Answer: [None Given] Answers: True False

F

Given the following delegate type declaration, which statement creates a lambda expression for a delegate named Product?delegate void MultiCalc(int x, int y, int z); MultiCalc Product = (int x * int y * int z); MultiCalc Product => (int x * int y * int z); MultiCalc Product => x * y * z; MultiCalc Product = (x, y, z) => x * y * z;

MultiCalc Product = (x, y, z) => x * y * z;

A Predicate delegate invokes a method that accepts 0 to 16 arguments and returns a boolean value. Selected Answer: [None Given] Answers: True False

T

A delegate type describes the method that the delegate can refer to. Selected Answer: [None Given] Answers: True False

T

A lambda expression is a shortcut technique for writing an anonymous method. Selected Answer: [None Given] Answers: True False

T

A method that has no name is known as an anonymous method. Selected Answer: [None Given] Answers: True False

T

If a delegate type specifies a void return type any lambda expression used with that delegate will also be void. Selected Answer: [None Given] Answers: True False

T

If you want to pass arguments to an Action delegate, you must specify the data type of each of the delegate's parameters. Selected Answer: [None Given] Answers: True False

T

The .NET built-in Func delegate type invokes a method that accepts 0 to 16 arguments and returns a value. Selected Answer: [None Given] Answers: True False

T

The compiler can determine the data type of a lambda expression's parameter from the delegate type declaration. Selected Answer: [None Given] Answers: True False

T

To use more than one parameter in a lambda expression, you write a comma-separated list and enclose the list in parentheses. Selected Answer: [None Given] Answers: True False

T

When a delegate refers to a method, you can use the delegate to call the method. Selected Answer: [None Given] Answers: True False

T

Given the following code, which statement creates an instance of the delegate? Selected Answer: [None Given]Answers: Welcome Hello = DisplayMessage; private void DisplayMessage(string greeting) delegate void Welcome(string str); MessageBox.Show(greeting);

Welcome Hello = DisplayMessage;

Which of the following built-in delegate types invokes a void method that accepts 0 to 16 arguments? Selected Answer: [None Given]Answers: multicast Action Predicate Func

action

Which of the following List methods will not accept delegates as arguments? Selected Answer: [None Given]Answers:ExistsForEachRemoveAll All of these accept delegates as arguments.

all of them

A delegate can reference ________. Selected Answer: [None Given]Answers: only a method that has a return type and a parameter list that matches that of the delegate type. only a method with a return type any method or object any method with a parameter list that matches that of the delegate type

any method with a parameter list that matches that of the delegate type.

An object that works like a reference variable that refers to a method is known as a ________. Selected Answer: [None Given]Answers: subroutine delegate predicate lambda

delegate

Given the following code, which statement creates a delegate type named Welcome? Selected Answer: [None Given]Answers: Welcome Hello = DisplayMessage; private void DisplayMessage(string greeting) delegate void Welcome(string str); MessageBox.Show(greeting);

delegate void welcome(string str);

Given the following code that creates a Predicate delegate and invokes the method, what is the name of the delegate? predicate<int> isodd = student ==> student 2....... Selected Answer: [None Given]Answers:x I sOdd Predicate student

isodd

A method that has no name is ________. Selected Answer: [None Given]Answers:not allowed in C# known as an anonymous method the same as a delegate All of these are true.

known as an anonymous method

A shortcut technique for writing an anonymous method is known as a(n) ________. Selected Answer: [None Given]Answers:anon method lambda expression predicate lambda delegate

lambda expression

You can use a delegate to reference a(n) ________. Selected Answer: [None Given]Answers: method object variable structure

method

A delegate that references multiple methods is known as a(n) ________ delegate. Selected Answer: [None Given]Answers: predicate action multitype multicast

multicast

Which of the following built-in delegate types invokes a method that accepts one argument and returns a boolean value? Selected Answer: [None Given]Answers: Predicate multi castFunc Action

predicate

When a delegate is ________ another method, the method's return type and parameter list must match that of the delegate type. Selected Answer: [None Given]Answers: joined to passed to reassigned to referred to

reassigned to

t is possible to write multiple statements in the body of a lambda expression so long as the ________. Selected Answer: [None Given]Answers:l ast statement is a return statement statements are enclosed in curly braces statements do not return a value delegate type is void

statements are enclosed in curly braces

Given the following code that creates a Predicate delegate and invokes the method, what would display if x? = 23 predicate <int> isOdd = student ==> student %2 == 1; if (isOdd(x)) message.box.show(the number is not even) Selected Answer: [None Given]Answers:false1 The number is not even.true

the number is not even

To create and use a delegate you must ________. Selected Answer: [None Given]Answers:declare a delegate type create an instance of the delegate type make the instance of the delegate type reference a method You must do all of these things.

you must do all


Kaugnay na mga set ng pag-aaral

Wong's - Chapter 31: Child with Endocrine Dysfunction, Chapter 31: The Child with Endocrine Dysfunction

View Set

viruses and immune system mastering bio

View Set

intermediate macroeconomics exam 3

View Set

Prep U Brunner 28: Structural, Infectious, Inflammatory Cardiac Disorders

View Set