Question: a. Define a class named ComparableSquare that extends Square class and implements Comparable. Implement the compareTo() method to compare the squares on the basis of
a. Define a class named ComparableSquare that extends Square class and implements Comparable. Implement the compareTo() method to compare the squares on the basis of the area.
- Create two ComparableSquare objects and find the smaller of two instances.
- Create an array of 5 ComparableSquare objects
- Sort the array in descending order
- Display the area of each object in the sorted array using displayOne() method.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
