Diff b/w Abstract Class and Interface

Abstract Class

Abstract class is a class but not a complete class for creating object
So we can not create a object for Abstract classes
But a reference can be created
Abstract classes are also called as "Partial Abstract classes"
After creating Abstract class it can not be instantiated by itself
It must be inherited by child classes
Abstract class provides set of rules to implement next class
Rules will be provided by Abstract methods
Abstract methods does not contain any definition
While inheriting abstract class from child class all abstract methods must be override other that child class should be a abstract class
If a class contain at least one abstract method then it must be declared as "Abstract class"
Partial abstract class may contain function with body and function without body
If a class contains all functions without body then it is called as "Fully Abstract Class"

Interface

Interface is not a class
Interfaces supports multiple inheritance
Interfaces are implementable
In Interface all methods are abstract methods and by default public Access Modifier
A class can implement  multiple interfaces
If a class has implement a interface that should be provide a implementation for all the methods
one interface can inherit another interface
 

No comments:

Post a Comment