Tuesday, 30 August 2016

Class Vs Abstract class Vs Interface

Q) What are the difference between the class, abstract classes and interfaces?
Ans);-
1.       Class are able to allow only concrete methods.
Abstract class are able to allow both concrete method and abstract methods.
Interfaces are able to allow only abstract methods.
2.       For classes only, we are able to provide both reference variable and objects.
For abstract classes and interface, we are able to provide only reference variable, we are unable to provide object.
3.       In case of interfaces, by default, all the variables are “public static final”.
In case of classes and abstract classes no default cases are existed for variables.
4.       In case of interfaces, by default, all the methods are “public and abstract”.
In case of classes and abstract classes, no default cases existed for method.
5.       To declare classes only class keyword is sufficient.
To declare abstract classes we have to use “abstract” keyword along with class keyword.
To declare interfaces, we have to use “interface” keyword.
6.       Constructer are possible in classes and abstract classes.
Constructer are not possible in interface.
7.       Classes are able to provide less sharability
Abstract classes are able to provide middle level sharability.
Interface are able to provide more sharabilty.



No comments:

Post a Comment