Go down
Thắng
Thắng
Admin
Posts : 55
Join date : 2018-03-14
https://toilathang.forumvi.com

Advanced OOP Empty Advanced OOP

Sun Mar 18, 2018 6:32 pm
Suppose the Employee class is derived from the Person class and the Person class defines an AddressChanged event. Which of the following should you not do to allow an Employee object to raise this event?
A. Make the Employee class call OnAddressChanged as needed.
B. Create an OnAddressChanged method in the Employee class that raises the event.
C. Make the code in the Person class that used to raise the event call the OnAddressChanged method instead.
D. Create an OnAddressChanged method in the Person class that raises the event.

Which of the following statements is nottrue 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 use addition to combine delegate variables into a series of methods and use subtraction to remove a method from a series.
D. You can make an array or list of delegate variables

If a class implements IDisposable, its Dispose method should do which of the following?
A. Free unmanaged resources.
B. Call GC.SuppressFinalize.
C. Free managed resources.
D. All of the above

Suppose you have defined the House and Boat classes and you want to make a HouseBoat class that inherits from both House and Boat. Which of the following approaches would not work?
A. Make HouseBoat implement both IHouse and IBoat interfaces
B. Make HouseBoat inherit from both House and Boat
C. Make HouseBoat inherit from Boat and implement an IHouse interface
D. Make HouseBoat inherit from House and implement an IBoat interface

Which of the following should you not do when building a custom exception class?
A. Make it implement Idisposable
B. Give it event handlers with parameters that match those defined by the System.Exception class.
C. Derive it from the System.Exception class, and end its name with Exception
D. Give it the Serializable attribute.
Thắng
Thắng
Admin
Posts : 55
Join date : 2018-03-14
https://toilathang.forumvi.com

Advanced OOP Empty Re: Advanced OOP

Sun Mar 18, 2018 6:36 pm
Which of the following statements about garbage collection is false?
A. An object’s Dispose method can call GC.SuppressFinalize to prevent the GC from calling the object’s destructor
B. In general, you can’t tell when the GC will perform garbage collection.
C. It is possible for a program to run without ever performing garbage collection
D. Before destroying an object, the GC calls its Dispose method.

Suppose the variable result is declared by the statement Func<float, float> result.
Which of the following correctly initializes result to an expression lambda?

A. result = (x) => return x * x;
B. Both a and c are correct.
C. result = (float x) => x * x;
D. result = x => x * x;

Suppose the Car class provides a Stopped event that takes as parameters sender and StoppedArgsobjects. Suppose also that the code has already created an appropriate StoppedArgs object named args. Then which of the following code snippets correctly raises the event?
A. if (Stopped) Stopped(this, args);
B. if (Stopped != null) Stopped(this, args);
C. raise Stopped(this, args);
D. if (!Stopped.IsEmpty) Stopped(this, args);

Which of the following statements about inheritance and events is false?
A. A class can define an OnEventName method that raises an event to allow derived classes to raise that event.
B. A derived class can raise a base class event by using code similar to the following: if (base.EventName != null) base.EventName(this, args);
C. A derived class inherits the definition of the base class’s events, so a program can subscribe to a derived object’s event.
D. A derived class cannot raise an event defined in an ancestor class

A program can use the IEnumerable and IEnumerator interfaces to do which of the following?
A. Use MoveNext and Reset to move through a list of objects
B. Use the yield return statement to make a list of objects for iteration.
C. Use foreach to move through a list of objects
D. Move through a list of objects by index.
Back to top
Permissions in this forum:
You cannot reply to topics in this forum