Microsoft
98-361 · Question #378
98-361 Question #378: Real Exam Question with Answer & Explanation
The correct answer is A. public int CompareTo(object obj). See the full explanation below for the reasoning.
Question
You are creating a new class named Polygon. You write the following code: class Polygon : IComparable { public double Length { get; set; } public double Width { get; set; } public double GetArea() { return Length * Width; } public int CompareTo(object obj) { // to be completed } } You need to complete the definition of the CompareTo method to enable comparison of the Polygon objects. Which of the following code segments should you use?
Options
- Apublic int CompareTo(object obj)
- Bpublic int CompareTo(object obj)
- Cpublic int CompareTo(object obj)
- Dpublic int CompareTo(object obj)
Community Discussion
No community discussion yet for this question.