Question: public abstract class Shape { protected String type; public abstract void draw(); } public class Rectangle extends Shape { public Rectangle() { type=Rectangle; } public

public abstract class Shape { protected String type; public abstract void draw(); } public class Rectangle extends Shape { public Rectangle() { type="Rectangle"; } public void draw() { System.out.println("Draw Shape: " + type); } } Shape[] shapearray = new Shape[20]; int i; // variable to use with loop 
public class Oval extends Shape { public Oval() { type="Oval"; } public void draw() { System.out.println("Draw Shape: " + type); } } public class Diamond extends Shape { public Diamond() { type="Diamond"; } public void draw() { System.out.println("Draw Shape: " + type); } }

Create an object of type Rectangle and assign it to shapearray at index/subscript 0

Create an object of type Oval and assign it to shapearray at index/subscript 1

Create an object of type Diamond and assign it to shapearray at index/subscript 2

Write a for loop from 0 to 2 and use the objects in shapearray to execute the draw() method Do not declare variables, that has been done for you, use variable i with the loop

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!