Krishan Dutt Sharma

Web Developer

Difference between Abstract and Interface

Abstract Class: -Abstract class provides a set of rules to implement next class -Rules will be provided through abstract methods -Abstract method does not contain any definition -While inheriting abstract class all abstract methods must be override -If a class contains at least one abstract method then it must be declared as an “Abstract Class” -Abstract classes cannot be instantiated, but a reference cannot be created -Reference depends on child class object’s memory -Abstract classes are also called as “Partial abstract classes” -Partial abstract class may contain functions with body and functions without body -If a class contains all functions without body then it is called as “Fully Abstract Class” (Interface) Interface: -If a class contains all abstract methods then that class is known as “Interface” -Interfaces support like multiple inheritance -In interface all methods r public abstract by default -Interfaces r implementable -Interfaces cannot be instantiated, but a reference can be created