Write 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.

Source Code:

interface Resizable {
void resizeWidth(int width);
void resizeHeight(int height);
}

class Rectangle implements Resizable {
int w, h;
public void resizeWidth(int width) {
w = width;
}
public void resizeHeight(int height) {
h = height;
}
public void display() {
System.out.println(“Width: ” + w + ” Height: ” + h);
}
}

public class TestResize {
public static void main(String[] args) {
Rectangle r = new Rectangle();
r.resizeWidth(10);
r.resizeHeight(20);
r.display();
}
}

Output: