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 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
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
Get step-by-step solutions from verified subject matter experts
