98-372 · Question #44
Which of the following methods is inherited from the ICloneable interface?
The correct answer is A. Clone. The Clone method is a member of the ICloneable interface. The Clone method of the ICloneable interface is used to create a new object that is a copy of the current instance. The Clone method can be implemented either as a deep copy or a shallow copy. In a deep copy, all objects a
Question
Which of the following methods is inherited from the ICloneable interface?
Options
- AClone
- BCompareTo
- CDispose
- DToString
How the community answered
(43 responses)- A70% (30)
- B5% (2)
- C7% (3)
- D19% (8)
Explanation
The Clone method is a member of the ICloneable interface. The Clone method of the ICloneable interface is used to create a new object that is a copy of the current instance. The Clone method can be implemented either as a deep copy or a shallow copy. In a deep copy, all objects are duplicated; whereas, in a shallow copy, just the top-level objects are duplicated and the lower levels hold references. The resulting clone needs to be of the identical type or a compatible type to the original instance. Answer: C is incorrect. The Dispose method of the IDisposable interface executes application defined tasks related with freeing, releasing, or resetting unmanaged resources. It is used to close or release unmanaged resources such as files, streams, and handles held by the object of a class that implements IDisposable interface. By principle, the Dispose method is used for all tasks related with freeing resources held by an object, or preparing an object to be reused. Answer: B is incorrect. The CompareTo method is a member of the IComparable interface. Answer: D is incorrect. All classes inherit the ToString, Equals, and GetType methods from the base Object class.
Topics
Community Discussion
No community discussion yet for this question.