Concrete class vs. Abstract class vs. Interface.
1. A concrete class has concrete methods, i.e., with code and other functionality. This class a may extend an abstract class or implements an interface.
2. An abstract class must contain at least one abstract method with zero or more concrete methods
3. An interface must contain only method signatures and static members.
4. An interface does not have definitions of the methods declared in it.
5. An abstract class may have some definition and at least one abstract method.
6. A subclass of an abstract class must either implement all the abstract methods of the abstract class or declare itself as abstract.
public abstract class A
{
public abstract void methodA();
public abstract void methodB();
}
class SubA extends A
{
void methodA()
{
// implementation
}
void methodB()
{
// implementation
}
}
interface interfaceA
{
void methodA(int x);
}
class classA implements interfaceA
{
// implementation for methodA and the rest of the class code if any.
}