What are differences between Interface and Abstract class

What are differences between Interface and Abstract class

Answer: Please see all differences below: 

Interface

Abstract Class

By default all methods are abstract when you define interface and cannot have define its implementationBut in abstract class you could define instance method with default implementation
Only public, static & final are permitted modifiers variables are permittedAll modifiers are  permitted for variables
Interface can be implemented using key word “Implements”Abstracts class can be extend using key word “extends”
By default variables in interface are finalAbstract class can contain non final variables
Members of interface are public by defaultBut in Abstract class you could use others modifiers as well like private, public or protected
A java class can implements multiple interfaceBut java class can only extends one Abstract class
Interface definition completely abstract and cannot be instantiatedYes, Abstract class also cannot be instantiated but could be invoked if main method avaialable.

 

Leave a Reply

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