HANDSOMEROOT

Tổng hợp một số câu hỏi trắc nghiệm Advanced features in C#



Advanced features in C# 

1. Which of the following statements about throwing exceptions is false?
    A. If you catch an exception and throw a new one to add more information, you should include the original exception in the new one’s InnerException property
    B. If you rethrow the exception ex with the statement throw, the exception’s call stack is reset to start at the current line of code.
    C. If you rethrow the exception ex with the statement throw ex, the exception’s call stack is reset to start at the current line of code
    D. Before a method throws an exception, it should clean up as much as possible, so the calling code has to deal with the fewest possible side effects


2. 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
    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);


3. Suppose you want to sort the Recipe class in question 6 by any of the properties MainIngredient, TotalTime, or CostPerPerson. In that case, which of the following interfaces would probably be most useful?
    A. Idisposable
    B. Icomparable
    C. Icomparer
    D. Isortable


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


5. 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. Create an OnAddressChanged method in the Person class that raises the event.
    B. Create an OnAddressChanged method in the Employee class that raises the event.
    C. Make the Employee class call OnAddressChanged as needed.
    D. Make the code in the Person class that used to raise the event call the OnAddressChanged method instead.


6. Which of the following returns true if variable result holds the value float.PositiveInfinity?
    A. result == float.PositiveInfinity
    B. float.IsInfinity(result)
    C. float.IsPositiveInfinity(result)
    D. All of the above.
   

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

8. 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


9. In the variable declaration Action processor, the variable process or 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.
   

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 HouseBoat class implements the IHouse interface implicitly and the IBoat interface explicitly. Which of the following statements is false?
    A. The code can use a HouseBoat object to access its IHouse members
    B. The code can use a HouseBoat object to access its IBoat members
    C. The code can treat a HouseBoat object as an IHouse to access its IHouse members
    D. The code can treat a HouseBoat object as an IBoat to access its IBoat members


12. Which the following statements about the base keyword is false?
    A. A constructor can use at most one base statement
    B. A constructor cannot use both a base statement and a this statement
    C. The base keyword lets a constructor invoke a different constructor in the same class
    D. If a constructor uses a base statement, its code is executed after the invoked constructor is executed.


13. Which of the following statements about exception handling is true?
    A. You can nest a try-catch-finally block inside a try, catch, or finally section.
    B. A try-catch-finally block must include at least one catch section and one finally section.
    C. An exception is handled by the catch section that has the most specific matching exception type.
    D. The code in a finally section executes if the code finishes without an error or if a catch section handles an exception but not if the code executes a return statement.


14. 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.


15. Which of the following should you not do when building a custom exception class?
    A. Derive it from the System.Exception class, and end its name with Exception
    B. Give it event handlers with parameters that match those defined by the System.Exception class.
    C. Make it implement Idisposable
    D. Give it the Serializable attribute.


16. Which of the following methods can you use to catch integer overflow exceptions?
    A. Use a try-catch-finally block.
    B. Use a checked block and a try-catch-finally block
    C. Check the Advanced Build Settings dialog’s overflow/underflow box, and use a try-catch-finally block.
    D. Either b or c


17. Which of the following statements about events is false?
    A. If an object subscribes to an event twice, its event handler executes twice when the event is raised.
    B. If an object subscribes to an event twice and then unsubscribes once, its event handler executes once when the event is raised.
    C. If an object subscribes to an event once and then unsubscribes twice, its event handler throws an exception when the event is raised.
    D. In a Windows Forms application, you can use the Properties window to subscribe and unsubscribe events, and to create empty event handlers


18. Suppose Fis declared by the statement Func F. Then which of the following correctly initializes Fto 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; };

Nhận xét

Bài đăng phổ biến từ blog này

[Share] CSDL Quản lý Shop Online

Hướng dẫn cài đặt VRML Pad và Cortona 3D Viewer

RANKING in SQL (ROW_NUMBER, RANK, DENSE_RANK,NTILE)