Difference and Similarities between Interface and Abstract Class in Java1 min read

Read More about : Interface in Java

Read More about : Abstract Class in Java

Difference and similarities between Interface and Abstract class in Java

Similarities between Interface and Abstract Class:-

  • We can’t create object for both.
  • All the abstract methods must be overridden by subclass.
  • Don’t have default constructor.
  • By using both we can go for dynamic polymorphism.
  • Both can contain static and final variable.
  • Both inherited from common domain of itself using extends keyword.
  • Both provide static method implementation.

Difference between Interface and Abstract Class:-

ABSTRACT CLASS INTERFACE
Abstract class can have abstract and non-abstract methodInterface can only have abstract method.Since java 8 ,it can have default and static method
Abstract class does not support mutiple inheritanceInterface supports multiple inheritance
Abstract class can have final ,non-final ,static and non-static variable.Interface has only static and final variable.
Abstract class can provide the implementation of interface.Interface can’t provide the implementation of abstract class.
An abstract class can extend another java class and implement multiple java interfaces.Interface can extend another java interface only.
It can have class members like private ,protected ,etc.Members are public by default.
Abstract class can not be instantiated but can be invokedInterface can not be instantiated or invoked
Abstract class has parametrised and non-parametrised constructor
but don’t have default constructor
Interface does not support the concept of constructor

Follow Java tag for more related article to Java Programming Language.

Bookmark(0)
Tags:

Add a Comment

Your email address will not be published. Required fields are marked *