You’d use an abstract class or interface here in order to make a common base class/interface that provides the void draw() method, e.g.
abstract class Shape() {
void draw();
}
class Circle extends Shape {
void draw() { ... }
}
...
Shape s = new Circle();
s.draw();
I’d generally use an interface. However you might use an abstract class if:
- You need/want to provide common functionality or class members (e.g. the
int imember in your case). - Your abstract methods have anything other than public access (which is the only access type allowed for interfaces), e.g. in my example,
void draw()would have package visibility.