Cid wrote:
When a method is declared abstract, it must not have a body and the
class containing it must also be declared abstract.
If the class is declared abstract but none of its methods are
abstract, then they must have bodies. But the class itself cannot be
instantiated. This presumably is what Oliver is referring to. (?)
Right.
To make it clear, two examples:
public abstract class A
{
public void methodA {...}; //not abstract
public abstract void methodB();
}
public interface B
{
public void methodB(); //abstract interface declaration
public void methodC(); //abstract interface declaration
}
public abstract class C implements B
{
public void methodB {...}; //not abstract and implements as default
behavior
}
In class C methodB is implemented with a default behavior which can be
overridden by children with a class specific implementation if required.
methodC *must* be implemented.
I mostly use this approach as it is flexible, though it requires more
discipline as forgetting the concrete chield implementation of methodB is
not immediately noticed at compile time..
Oliver