I face this question in many interviews but here i exactly want to know the big difference between interface and abstract class in object oriented programming.
Anyone there?
I face this question in many interviews but here i exactly want to know the big difference between interface and abstract class in object oriented programming.
Anyone there?
Interface: 1.Interface is not class 2.Interface use for – Data Abstraction, Future implementation. 3. Interface contains only the abstract members. 4.Interface contains the declaration, the class which will implement it will have to define/add the logic on it.
Abstract Class 1.Abstract class is a class 2.Abstract class is use for a base class. 3. Abstract class contains both Abstract + normal members 4.The abstract members have only the declaration (like Interface),but the normal members are getting define.
One major difference of interface and abstract class is:
if interface contains 9 methods and we implements that interface then we need to override all 9 methods in our class.
if we take one abstract class and we extends that abstract class no need to override all 9 methods override only that method that wee need.
The main difference is that in interface we can only define the methods and variable and give body/values where it is implemented by overriding. Where abstract class has the property of a normal class and an interface. We can just make the variables and methods abstract like interface and we can also add variables and methods with body/value in the same class.