Override purpose

This is a very naive question, but here it is:

An override method from a base class will mean that subclass calls will invoke a derived, overridden method, right?

Thus, if there is no override annotation, the method in the base class will be called. Thus, the override method will only serve to document the intent — call one version of the method over another.

In this case?

This leads me to the following question:

What is the difference between an abstract class from which 5-6 classes can be called, but the methods inherited in the derived classes are not reevaluated, but one class (static or irrelevant) used by these 5-6 classes?

+7
source share
4 answers

@Override annotations are ONLY for detecting compile-time errors. This does not affect runtime override behavior. The idea is that you give the compiler the ability to tell you that the name or signature of your method is incorrect.

+10
source

An override annotation is simply a marker indicating that a method overrides a superclass method.

This does not affect runtime. See here:

http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Override.html

+1
source

Using abstract is an architectural project to ensure that users must either implement an abstract method (declared, but not implemented in the base class), or they all have access to the same base methods and data (this is the same as the last example, which you gave).

0
source

Thus, if there is no redefinition of the annotation, the method in the base class will be called.

Not. An override method in a derived class will always be called.

So, overriding a method will only serve to document the purpose of invoking one version of a method over another.

In this case?

Not. According to other answers, he tells the compiler to insist on overriding something.

0
source

All Articles