An abstract class is a class that has one or more abstract methods. First of all, what is an abstract method? I will explain.
An abstract method is a method that does not have an implementation and defines only the signature (method name, argument type, number of arguments) and return type.
Specifically, it is as follows. Notice where there is abstract at the beginning and there is no {} after the argument parentheses.
abstract Return type number Method name (argument);
Next, write the abstract class as follows.
abstract class class name{
abstract Return type name Method name(argument)
}
The advantage of having a method in an abstract class is that you can force the developer to override the method.
It is necessary to override the abstract method and describe the processing content for each subclass that inherits the abstract class.
However, the processing content can be separated for each subclass. The processing content is different for each subclass, However, if you have to describe the processing contents, you will take advantage of having an abstract class method.
Recommended Posts