On many occasions I have seen people use the abstract modifier in a class like the following :
abstract class someclass{
//Mas codigo...
}
I know that there are then modifiers like: private, protected, public, abstract etc. and that some classes have the abstract modifier , I know that the question can become too broad, but what matters most to me is to understand three things:
- What is the abstract modifier for and in what cases is it used.
- What is the impact of using the abstract modifier in a class and what should be considered when doing so.
- What interfaces are for, but not how they are used. Just what they are for and in what cases they are used.
Now, I know that the word extends can be used in a class to extend another class, what this will do is an override of the constructor of the class in which this word is used and it will automatically obtain all the properties and methods of another class, apart from of having your own constructor, this is not new and I have seen it in other programming languages such as javascript, a language in which generic classes are used, but I also have the doubt in the word implements , what is really the difference between implement and extend ?, and what things can be implemented and extended?, what things can not be implemented or extended?, this has me thinking a lot, since I have never used neither an interface nor the abstract modifier for those reasons.
What really interests me the most is to know a little more about the abstract modifier, thank you very much in advance!
Abstract allows you to create an abstract class. Abstract classes cannot be instantiated; that is, they are not designed so that you can create an object with them, but rather serve as the basis for other classes; that is, they can only be inherited (extended) by other classes.
implements allows your class to implement an interface. An interface is like a contract, which binds the class that implements it to have the methods that the interface requires.
An interfacen contains the structure of the methods it uses, but not the content, which must be implemented in the class that implements said interface.
Read a bit about the concept of polymorphism. In Java polymorphism is implemented with interfaces.