1.Which of the following is a valid delegate definition? a.private delegate float MyDelegate(float); b.private delegate MyDelegate(x); c.private...

Question:

1.Which of the following is a valid delegate definition?
a.private delegate float MyDelegate(float);
b.private delegate MyDelegate(x);
c.private delegate MyDelegate(float x);
d.private delegate void MyDelegate(float x);
2.Which of the following statements is not true of delegate variables?
a.You need to use a cast operator to execute the method to which a delegate variable refers.
b.A struct or class can contain fields that are delegate variables.
c.You can make an array or list of delegate variables.
d.You can use addition to combine delegate variables into a series of methods and use subtraction to remove a method from a series.
3.If the Employee class inherits from the Person class, covariance lets you do which of the following?
a.Store a method that returns a Person in a delegate that represents methods that return an Employee.
b.Store a method that returns an Employee in a delegate that represents methods that return a Person.
c.Store a method that takes a Person as a parameter in a delegate that represents methods that take an Employee as a parameter.
d.Store a method that takes an Employee as a parameter in a delegate that represents methods that take a Person as a parameter.
4.If the Employee class inherits from the Person class, contravariance lets you do which of the following?
a.Store a method that returns a Person in a delegate that represents methods that return an Employee.
b.Store a method that returns an Employee in a delegate that represents methods that return a Person.
c.Store a method that takes a Person as a parameter in a delegate that represents methods that take an Employee as a parameter.
d.Store a method that takes an Employee as a parameter in a delegate that represents methods that take a Person as a parameter.
5.In the variable declaration Action processor, the variable processor represents which of the following?
a.Methods that take no parameters and return an Order object.
b.Methods that take an Order object as a parameter and return void.
c.Methods that take an Order object as a parameter and return an Order object.
d.Methods provided by the Action class that take no parameters and return void.
6.In the variable declaration Func processor, the variable processor represents which of the following?
a.Methods that take no parameters and return an Order object.
b.Methods that take an Order object as a parameter and return void.
c.Methods that take an Order object as a parameter and return an Order object.
d.Methods provided by the Action class that take no parameters and return void.
7.Suppose F is declared by the statement Func F. Then which of the following correctly initializes F to an anonymous method?
a.F = (float x) { return x * x; };
b.F = delegate { return x * x; };
c.F = float Func(float x) { return x * x; };
d.F = delegate(float x) { return x * x; };
8.Suppose the variable note is declared by the statement Action note. Then which of the following correctly initializes note to an expression lambda?
a.note = { return x * x; };
b.note = () { return x * x; };
c.note = () => MessageBox.Show("Hi");
d.note = MessageBox.Show("Hi");
9.Suppose the variable result is declared by the statement Func result. Which of the following correctly initializes result to an expression lambda?
a.result = (float x) => x * x;
b.result = (x) => return x * x;
c.result = x => x * x;
d.Both a and c are correct.
10.Which of the following statements about statement lambdas is false?
a.A statement lambda can include more than one statement.
b.A statement lambda cannot return a value.
c.A statement lambda must use braces, { }.
d.If a statement lambda returns a value, it must use a return statement.
Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  answer-question

Oracle 12c SQL

ISBN: 978-1305251038

3rd edition

Authors: Joan Casteel

Question Posted: