Difference between Interface and Abstract Class
Below are the common points to be remembered,
- Abstract classes can have abstract plus nonabstract methods while Interfaces all methods needs to be abstract only.
- Abstract classes can have variables and method implementation whereas Interfaces are not allowed to declare variables and the methods are abstract only. (No implementation)
- Abstract class members are private by default even they can be changed, In Interface it is public by default and you cannot change the same.
- To declare abstract classes Abstract keyword is used, for Interface it is Interface
- Abstract classes and Interfaces are not allowed to create an instance.
- Abstract classes can have a constructor but Interface do not.
No comments:
Post a Comment