Am I correct that declaring a method abstract automatically makes it virtual?
That is, in subclasses I can override it many times and at runtime, the method corresponding to the runtime type of the object will be called?
Is it possible to declare an abstract non-virtual method? That is, the method which must be implemented in a non-abstract subclass and can not be overridden?
Yes, abstract methods are virtual by definition; they must be overridable in order to actually be overridden by subclasses:
Conversely you can’t declare an abstract non-virtual method, because if you could, you would have a method that can’t be implemented and thus can never be called, making it rather useless.
However, if you want to have a class implement an abstract method but not allow any of its subclasses to modify its implementation, that’s where
sealedcomes in. An example:Notice that while the abstract method is (implicitly) virtual, the implementation in the concrete base class is non-virtual (because of the
sealedkeyword).