Abstract Methods don't have body?

Max_S picture Max_S · Aug 7, 2013 · Viewed 10.8k times · Source

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);

}

Answer

Suresh Atta picture Suresh Atta · Aug 7, 2013

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.