I have an interface named SHAPE. CIRCLE and RECTANGLE are two classes implementing this interface. Now I have to write a class (i have an option to write a class only) CIRCULARRECTANGLE which will extend the properties of CIRCLE and RECTANGLE. How to do this in Java?
I have an interface named SHAPE . CIRCLE and RECTANGLE are two classes implementing
Share
Since Java extends one class at a time, you will need to create abstract classes to fit your criteria.
Example:
Update: My first attempt will never work, hence my update:
Since my first attempt never extended a
Circle, you will need to keep reference to eiter aCircleor aRectanglelike so:The purpose of the constructor is to keep reference to a circle.