Difference between abstract class and interface
Difference between abstract class and interface :
Abstract class
|
Interface
|
1.Abstract class contains constants, variables, constructors, concrete methods and abstract methods.
|
1.Interface contains constants and public abstract methods.
|
2.Use extends keyword to extend the abstract class.
|
2.Use 'implements' keyword to implement the interface.
|
3.Abstract class doesn't support multiple inheritance i.e. after extends keyword more than one class name is not allowed.
|
3.Interface supports multiple inheritances i.e. after implements keyword more than one class name is allowed.
|
4.When you are writing abstract methods in abstract class we should write abstract keyword.
|
4.When you are writing abstract methods in interface, no need to write abstract keyword.
|
5.If you want to declare final static variable and public abstract methods in abstract class, we should declare them explicitly.
|
5.By default all the variables are final and static and all the methods are public and abstract.
|
No comments:
Post a Comment