Answer to Question #300591 in Java | JSP | JSF for rim

Question #300591

Create an abstract class called figure which has an abstract method called draw().

Make the subclasses called Filled_Rectangle, Filled_Arc and override the draw()

function in which you would just print the message regarding the current object.


1
Expert's answer
2022-02-21T13:35:15-0500






abstract class Figure {
	abstract void draw();
}


class Filled_Rectangle extends Figure {
	void draw() {
		System.out.println("Filled Rectangle");
	}
}


class Filled_Arc extends Figure {
	void draw() {
		System.out.println("Filled Arc");
	}
}


class App {


	public static void main(String[] args) {
		Figure figure = new Filled_Rectangle();
		figure.draw();
		figure = new Filled_Arc();
		figure.draw();
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS