Java Discussion Forums

There's no such thing as a stupid question. Ask. Discuss. Learn.

Difference between Abstract class and interface?

Abstract classes have a default constructor and are called when the specific subclass is instantiated.
Interface has no constructor and could not be instantiated.

Misha Kapoor 5 months ago
  • Misha Kapoor

    Difference between Abstract class and interface are as follows:

    Abstract Class:
    Abstract classes have a default constructor and are called when the specific subclass is instantiated.
    Contains Abstract methods and Non Abstract methods.
    The class that extends the Abstract class should implement all the methods, only Abstract methods must be implemented in the concrete subclass.
    Abstract class contains instance variables.

    Interface:
    Has no constructor and could not be instantiated.
    Abstract method should be declared.
    Classes that implement the interface should provide implementation for all the methods.
    The interface contains only constants.


  • Amit Negi

    The main difference abstract class and interface:
    Abstract Class:


    1. An abstract class may contain non-final variables.
    2. Java interface are implicitly abstract and cannot have implementations.
    3. Variables declared in a Java interface is by default
    4. A Java abstract class can have instance methods that implements a default behavior.
    5. Abstract classes has default constructor and cannot inherited.
    6. The class that extends the Abstract class should implement
    7. implemented in the concrete subclass.
    8. Abstract class contains instance variables.
    9. Abstract class contains instance variables.
      Interface:
    10. Interface have no constructor .
    11. Abstract method should be declared.
    12. The interface contains only constants.


  • Whitelisted Links