Question: Classes such as Rectangle2D.Double, Ellipse2D.Double, and Line2D.Double implement the Shape interface. The Shape interface has a method: Rectangle getBounds () that returns a rectangle completely

Classes such as Rectangle2D.Double, Ellipse2D.Double, and Line2D.Double implement the Shape interface. The Shape interface has a method:

Rectangle getBounds () that returns a rectangle completely enclosing the shape. Consider

Rectangle getBounds () that returns a rectangle completely enclosing the shape. Consider the method call: Shape s = . . .; Rectangle r = s.getBounds (); Explain why this is an example of polymorphism.

Step by Step Solution

3.39 Rating (152 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

This code snippet is an example of polymorphism because it shows the ability of different class instances to be treated as instances of the same paren... View full answer

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 Java Programming Questions!