Question
1. Create an interface, named Shape, with two methods: surface and volume 2. Create an interface name Print, with method print 3. Create a class
1. Create an interface, named Shape, with two methods: surface and volume 2. Create an interface name Print, with method print 3. Create a class called Sphere with one field radius, that extends both these interfaces, and define the methods for surface and volume. In addition, define print method that prints radius, surface and volume. 4. Create a class called Cube with three fields, height,length and width, that extends both these interfaces, and define the methods for surface and volume. In addition, define print method that prints height, length and width, surface and volume. 5. Write a sub-class Circle of Sphere, and over-ride the method surface so that it returns the perimeter of a circle, and over-ride the method volume so that it returns the area of a circle. Do not over-ride the method print. 6. Create a driver class, where instantiate the following: a. Sphere s= new Sphere(2.5); b. Circle c = new Circle(2); c. Cube b = new Cube (2, 3.45 ,4); 7. In this driver class, run the following and verify the output: a. s.print(); b. c.print(); c. b.print();
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started