ProAnswers.org

Differences between abstract class and interface

what are the differences between abstract class and interface

Abstract Class:
1.Can have abstract methods and concrete methods
2.All methods are not by default public
3.An abstract class can extend another abstract class
4.The extended class can override the methods of its super class and its hierarchy
5.All abstract methods must have abstract access modifier

eg.
abstract class Shape
{
abstract void area();
abstract void perimeter();
void someMethod() // concrete method
{

}
}

Interface:
1.Can have only method signatures and static final members
2.All methods by default abstract and public
3.An interface can extend another interface but not a class
4.An implementing class can implement multiple interfaces
5.All methods in an interface must not have abstract access modifier.

eg.
interface Shape
{
void area();
void perimeter();
}