I understand that in abstract classes methods be both abstract, or not. But why can I not create an abstract method in a "normal", non-abstract class?
Thanks in advance for any explanation!
Abstract method basically says, that there is no implementation of the method and it needs to be implemented in a subclass. However if you had an abstract method in a non-abstract class, you could instantiate the class and get an object, that would have an unimplemented method, which you would be unable to call.
Having an abstract method prevents a class from being instantiated, thus making it a de-facto abstract class. Java insists on you declaring this fact explicitly for consistency: technically, Java compiler does not need this additional mark in order to decide if a class is abstract based on the presence of abstract methods, but since you may want to make a class abstract without making any of its methods abstract, requiring the declaration on the class was the way to go.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With