Define an interface, called VolumeArea, within which there\'re: a static and fin
ID: 3571975 • Letter: D
Question
Define an interface, called VolumeArea, within which there're: a static and final variable PI (with the value 3.14159), and two abstract methods volume(double radius) and area(double radius). Write another class MyCircle which implements the interface VolumeArea Overriding the two methods: volume(double radius) to return a value zero (as the volume of a circle is 0). and area(double radius) to return the area of the circle. Write the third class MySphere. also implements VolumeArea Overriding the two methods: volume(double radius) to calculate and return the volume of the sphere (using (4 pi*r*r*r)/3); area(double radius) to calculate and return the surface area of the sphere (using 4 pi*r*r). Draw a UML diagram that involves VolumeArea. MyCircle. and MySphere Write a main class with the main method to test the methods in MyCircle and MySphere. set the radius of the circle and sphere both to 3.5. And display the results.Explanation / Answer
Defining Interface :-
Interface VolumeArea
{
staic final PI = 3.14159;
abstract volume(double radius);
abstract area (double radius);
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.