Program 07 Resizable interface
Program 07 Resizable interface
Develop a JAVA program to create an interface Resizable with methods resizeWidth(int width) and
resizeHeight(int height) that allow an object to be resized. Create a class Rectangle that implements
the Resizable interface and implements the resize methods.
// Resizable interface
interface Resizable {
this.width = width;
this.height = height;
@Override
this.width = width;
@Override
public void resizeHeight(int height) {
this.height = height;
return width;
return height;
rectangle.displayInfo();
// Resizing the rectangle
rectangle.resizeWidth(15);
rectangle.resizeHeight(8);
rectangle.displayInfo();
In this program, the Resizable interface declares the methods resizeWidth and resizeHeight.
The Rectangle class implements this interface and provides the specific implementation for resizing the
width and height. The main method in the ResizeDemo class creates a Rectangle object, displays its
original information, resizes it, and then displays the updated information.
Output
$ java ResizeDemo