Earlier nosotros convey learnt near interface inward THIS POST in addition to abstract class THIS POST. Now let's sweat to understand similarities difference betwixt abstract shape in addition to interface in coffee software evolution language. Interviewer tin inquire you lot this inquiry when you lot volition acquire for selenium webdriver with coffee interview. There are few similarities in addition to differences betwixt interface in addition to abstract class in coffee software evolution linguistic communication every bit bellow.
Similarities- Interface can non live on instantiated. Same way, you lot tin non instantiate abstract class.
- That agency you lot tin non practise object of interface or abstract class.
Difference
Differences betwixt interface in addition to abstract shape inward coffee software evolution linguistic communication are every bit bellow.
Interface | Abstract Class |
We tin role interface keyword to declare interface. | We tin role abstract keyword to declare abstract class. |
Interface tin concord exclusively abstract methods(without implementation). | Abstract shape tin concord abstract(without implementation) every bit good every bit non abstract methods. |
Interface tin live on implemented using implements keyword. | Abstract shape tin live on extended using extends keyword. |
We tin accomplish multiple inheritance using interface every bit nosotros tin implement multiple interfaces to whatever class. | Abstract shape doesn't back upward multiple inheritance every bit nosotros tin non extend to a greater extent than than 1 class. |
Interface tin non concord master copy method, static methods or constructor. | Abstract shape tin concord master copy method, static methods or constructor. |
Also it tin concord exclusively static in addition to concluding variables in addition to mandatory to initialize them. | It tin concord static, non static, final, non concluding variables in addition to also it is non mandatory to initialize them. |
We tin accomplish 100% abstraction using interface every bit all methods are abstract yesteryear default. It tin non concord concrete methods. | We tin accomplish partial(0% to 100%) abstraction using abstract shape every bit it tin concord abstract every bit good concrete methods too. |
When you lot add together a novel method inward existing interface it breaks all its implementation in addition to you lot necessitate to render an implementation inward all clients which is non good. | By using abstract shape you lot tin render default implementation inward super shape yesteryear creating concrete method. It is non required to render its implementation inward sub class. |
These are the difference betwixt abstract shape in addition to interface inward java software evolution linguistic communication which tin helps you lot to select abstract shape or interface.