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:
