Why add an abstract keyword before abstract methods

This may be a useless question, Just out of my curiosity.

Why are we forced to add a keyword abstractbefore abstract methodfrom abstract classwhen we do not need to add a keyword in the case interface?

Possible answer:
 As an abstract class, there may be a combination of concrete and abstract methods, the keyword "abstract" is used to determine which method is abstract.
But
when we do not give any body to any methods and use it ;at the end of the declaration, then what could go wrong if it is automatically considered as an abstract method?

+4
source share
4 answers

Why are we forced to add an abstract keyword before the abstract method of an abstract class, when we do not need to add a keyword in the case of an interface.

Inside interfaces, all method definitions are implicit abstract. However, you can specify a keyword, but there will be no difference.

However, in classes abstract, when you want to designate a method as abstract, you need to enter a keyword abstract. This makes the code more understandable and understandable.

+4
source

Not all methods of an abstract class must be abstract. In fact, you can have an abstract class without abstract methods.

, , interface, public abstract, .

+4

, , , , , .

+1

  • , , ,

Btw. java 4 .

0

All Articles