Microsoft
98-361 · Question #378
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() {…
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)
How the community answered
(23 responses)- A78% (18)
- B4% (1)
- C13% (3)
- D4% (1)
Community Discussion
No community discussion yet for this question.