How are interfaces different from abstract classes? code example

Example 1: abstract classes and interfaces in java

abstract class have no implementation of methods functions inside it. the classes which extending abstract class have to implement it

Example 2: abstract classes vs interfaces

Interface 
1) Interface contains only abstract methods 
2) Access Specifiers for methods in interface
must be public
3) Variables defined must be public , static ,
final
4) Multiple Inheritance in java is implemented
using interface
5) To implement an interface we use
implements keyword

Abstract Class
1) Abstract class can contain abstract methods,
concrete methods or both
2) Except private we can have any access
specifier for methods in abstract class.
3) Except private variables can have any access
specifiers
4)We cannot achieve multiple inheritance using
abstract class.
5)To implement an interface we use extends
keyword

Tags:

Java Example