Talk with Thang
Bạn có muốn phản ứng với tin nhắn này? Vui lòng đăng ký diễn đàn trong một vài cú nhấp chuột hoặc đăng nhập để tiếp tục.

Go down
Admin
Admin
Admin
Tổng số bài gửi : 44
Join date : 26/02/2018
https://talkwiththang.forumvi.com

BTNB _ Advanced OOP  Empty BTNB _ Advanced OOP

Tue Mar 06, 2018 12:51 am
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.
Admin
Admin
Admin
Tổng số bài gửi : 44
Join date : 26/02/2018
https://talkwiththang.forumvi.com

BTNB _ Advanced OOP  Empty Re: BTNB _ Advanced OOP

Tue Mar 06, 2018 12:57 am
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.
Admin
Admin
Admin
Tổng số bài gửi : 44
Join date : 26/02/2018
https://talkwiththang.forumvi.com

BTNB _ Advanced OOP  Empty Re: BTNB _ Advanced OOP

Tue Mar 06, 2018 9:05 pm
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 = () => MessageBox.Show("Hi");
B. note = { return x * x; };
C. note = () { return x * x; };
D. note = MessageBox.Show("Hi");

If a class has unmanaged resources and no managed resources, it should do which of the following?
A. Implement IDisposable and not provide a destructor.
B. Implement IDisposable and provide a destructor.
C. Not implement IDisposable and not provide a destructor.
D. Not implement IDisposable and provide a destructor.

In the variable declaration Action<Order> processor, the variable process or represents which of the following?
A. Methods that take an Order object as a parameter and return void.
B. Methods that take no parameters and return an Order object
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.

Which of the following statements about destructors is false?
A. Destructors are called automatically
B. Destructors cannot assume that other managed objects exist while they are executing.
C. Destructors are inherited.
D. Destructors cannot be overloaded

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 treat a HouseBoat object as an IHouse to access its IHouse members
B. The code can use a HouseBoat object to access its IHouse members
C. The code can treat a HouseBoat object as an IBoat to access its IBoat members
D. The code can use a HouseBoat object to access its IBoat members
Admin
Admin
Admin
Tổng số bài gửi : 44
Join date : 26/02/2018
https://talkwiththang.forumvi.com

BTNB _ Advanced OOP  Empty Re: BTNB _ Advanced OOP

Tue Mar 06, 2018 9:26 pm
Which of the following is not a good use of interfaces?
A. To reuse the code defined by the interface.
B. To allow the program to treat objects from unrelated classes in a uniform way.
C. To simulate multiple inheritance.
D. To allow the code to treat objects that implement the interface polymorphically as if they were of the interface’s “class.”

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. Icomparable
B. Isortable
C. Icomparer
D. Idisposable

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 Personas 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

Which of the following methods can you use to catch integer overflow exceptions?
A. Either b or c
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. Use a try-catch-finally block.

Suppose you want to make a Recipe class to store cooking recipes and you want to sort the Recipes by the MainIngredient property. In that case, which of the following interfaces would probably be most useful?
A. Idisposable
B. Isortable
C. Icomparable
D. Icomparer
Admin
Admin
Admin
Tổng số bài gửi : 44
Join date : 26/02/2018
https://talkwiththang.forumvi.com

BTNB _ Advanced OOP  Empty Re: BTNB _ Advanced OOP

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

Which of the following is a valid delegate definition?
A. private delegate void MyDelegate(float x);
B. private delegate MyDelegate(float x);
C. private delegate MyDelegate(x);
D. private delegate float MyDelegate(float);

Which of the following statements about throwing exceptions is false?
A. 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
B. 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
C. 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.
D. 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

Suppose the MovedEventHandler delegate is defined by the statement delegate void MovedEventHandler(). Which of the following correctly declares the Moved event?
A. public MovedEventHandler MovedEvent;
B. public event MovedEventHandler MovedEvent;
C. public event Action MovedEvent;
D. Both b and c are correct.

Which of the following statements about events is false?
A. In a Windows Forms application, you can use the Properties window to subscribe and unsubscribe events, and to create empty event handlers
B. If an object subscribes to an event twice, its event handler executes twice 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. If an object subscribes to an event twice and then unsubscribes once, its event handler executes once when the event is raised.
Sponsored content

BTNB _ Advanced OOP  Empty Re: BTNB _ Advanced OOP

Về Đầu Trang
Permissions in this forum:
Bạn không có quyền trả lời bài viết