Difference between abstract classes and interfaces | Sololearn: Learn to code for FREE!
+ 2

Difference between abstract classes and interfaces

What is the difference between interface classes and abstract classes and why should I choose one over the other. ūüėĀūüôāūüėĀ

8th Apr 2018, 1:56 AM
Yusuf
Yusuf - avatar
3 Réponses
+ 4
Practicly, the main differences are: Abstract classes can have implemented methods, but it will hold the place on the unique class inheritance. So when you inherit from an abstract class you won't have the possibility of inheriting from any other one. It'll have left just interface implementations. Interfaces are pure abstract classes, without any implementation. You can inherit from more than one interface. Interfaces are usually used as a way to verify identity, and abstract classes can be used this way too. Abstract classes are preferred when it is needed to implement methods in the base class (though we can use interfaces and normal classes with some design trick for this purpose :D).
8th Apr 2018, 3:56 AM
Maicon Mauricio
Maicon Mauricio - avatar
+ 2
These is something i want to add.. As a real life programer developer you never call abstract method explicitly . On arising the certain conditions machine call itself.. "we only do implimentation".. you learn more the detail in "Event Handling.." and second point --->> abstract class represent properties(variable) and behaviour (method) of an object. Interface only represent behaviour of an object( becoz of static data member)
8th Apr 2018, 6:13 AM
Arun Tomar
Arun Tomar - avatar
8th Apr 2018, 2:18 AM
Aidos Zhakupov
Aidos Zhakupov - avatar