Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you help me solve the questions? With java public abstract class Shapes extends Graphics abstract double getArea: public interface Drawer { void draw(); }

Can you help me solve the questions? With java

image text in transcribed

public abstract class Shapes extends Graphics abstract double getArea: public interface Drawer { void draw(); } In addition to this, Graphics class has the following methods: drawRect(int x, int y, int width, int height): Draws the outline of the specified rectangle. drawQval(int x, int y, int width, int height): Draws the outline of an oval. /*Declare a class with name Rectangle which is subclass of Shapes and able to use method of Drawer interface Finally, the following main routine is called: Public class Test{l public static void main(String[] args) { Circle cl=new Circle(3.0); Shapes shapel-circlel; Drawer shapes={c1, new Rectangle(3,4)}; for(Drawer g: shapes) { g.draw0:} circle1.getArea: } } f. Give the name of polymorphic references in main program. b. * define two instance variables x height and width(integer)*/ c. /* define a constructor for Rectangle class such that it initializes the instance variable in part (6)*/ d. /*override the draw() method in drawer interface such that it calls the drawRect( method inside of it.*/ g. Give the output of the main program. e Moverride the getArea() method in Shapes class such that it finds the area of Rectangle object.*/ h. If I add the following lines in main program what will be the result: Shapes shape2=new Shapel; shape2.getAreal } In addition to Shapes and Rectangle class, there is Circle class as follows: public class Circle extends Shapes implements Drawer{ double r=0.0. public Circle (double t) {this..=r;} double getArea({ return Math.PI*r*r}; void draw({ drawQval(0, 0, (int)r, (int)r): } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

Exposure to SQL desirable but not required

Answered: 1 week ago

Question

Strong analytical, communication, and problem-solving skills

Answered: 1 week ago