Question: 1 . Assume the Circle class from the classroom. The Comparable interface enables an object to compare itself with another object of the same type.

1. Assume the Circle class from the classroom. The Comparable interface enables an
object to compare itself with another object of the same type. It requires a single
method to be implemented, the public int compareTo(Circle circle). This
method expects another object of the same type (Circle) and compares it to this
object, the one that the method is being called upon.
!"Write the class declaration (not the entire body of the class!) so that it
implements the Comparable interface.
!"Implement the compareTo method. If the radius of the circle is less than
this object's radius return 1; return 0 if both values are the same; return
-1 if circle's radius is greater than this object's.
2. Extend the class Container given below.
abstract class Container {
abstract boolean isFull();
abstract void add(int volume);
abstract void remove(int volume);
}
3. Implement the interface Fillable below.
public interface Fillable {
boolean isFull();
void add(int volume);
void remove(int volume);
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!