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.
11. Suppose the MovedEventHandlerdelegate is defined by the statement delegate void
MovedEventHandler(). Which of the following correctly declares the Moved event?
a. public MovedEventHandlerMovedEvent;
b. public event MovedEventHandlerMovedEvent;
c. public event Action MovedEvent;
d. Both b and c are correct.
12. Suppose the Employee class is derived from the Person class and the Person class defines
anAddressChangedevent. Which of the following should you not do to allow an Employee
object to raise this event?
a. Create an OnAddressChangedmethod in the Person class that raises the event.
b. Create an OnAddressChangedmethod in the Employee class that raises the event.
c. Make the Employee class call OnAddressChangedas needed.
d. Make the code in the Person class that used to raise the event call the
OnAddressChangedmethod instead.
13. Which of the following statements subscribes the myButton_Clickevent handler to catch the
myButtoncontrol’s Click event?
a. myButton.Click += myButton_Click;
b. myButton_Click += myButton.Click;
c. myButton_Click handles myButton.Click;
d. myButton.Click = myButton_Click;
14. Suppose the Car class provides a Stopped event that takes as parameters sender
andStoppedArgsobjects. Suppose also that the code has already created an appropriate
StoppedArgsobject named args. Then which of the following code snippets correctly
raises the event?
a. if (!Stopped.IsEmpty) Stopped(this, args);
b. if (Stopped) Stopped(this, args);
c. if (Stopped != null) Stopped(this, args);
d. raise Stopped(this, args);

CS answers

Leave A Comment

Please enter your name. Please enter an valid email address. Please enter message.