Skip to content
@Override
is not a keyword, it is an optional annotation that helps the compiler check that you indeed are overriding a method. If you say @Override
but there is no method to override, the compiler will tell you that you’ve probably made a typo. Rename method1
to method12
to see the effect.
- Interface cannot have any implementations, while abstract class may optionally provide implementations for some of its methods. In addition, interfaces cannot have data members.
- Defining a method as abstract means that the derived class must provide an implementation. Not declaring it abstract says that derived classes simply can provide their own implementation, but they do not need to.