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 implementation But in abstract class you could define instance method with default implementation
Only public, static & final are permitted modifiers variables are permitted All 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 final Abstract class can contain non final variables
Members of interface are public by default But in Abstract class you could use others modifiers as well like private, public or protected
A java class can implements multiple interface But java class can only extends one Abstract class
Interface definition completely abstract and cannot be instantiated Yes, 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 *