Java – Abstract Methods don’t have body

abstract, abstract-methods, java

I am new to Java (reading books for 4 months now). So probably my question can appear too simple. My understanding is that abstract methods don't have a body and can't provide implementation

So how does this works?

public abstract void fillRect (int x, int y, with, height);

I did't point the question clearly. We've got abstract method. Why does it draw a rectangle if I doesn't provide a body, just parameters.

For example

public void paint (Graphics g) {g.fillRect (5, 5, 30, 30);}

Best Solution

Also read docs

When an abstract class is subclassed, the subclass usually provides implementations for all of the abstract methods in its parent class. However, if it does not, the subclass must also be declared abstract.