override of static method and final method

前端 未结 1 2017
轮回少年
轮回少年 2021-01-15 12:53

I know in Java, static method can not be overriden by the subclass.

Two questions:

1

1条回答
  •  生来不讨喜
    2021-01-15 13:28

    Static methods aren't called on a particular instance - so they can't be called polymorphically. They are called on the type itself - nothing about the binding relies on any information which is only available at execution time. The point about polymorphic calls is that the method implementation which ends up being executed depends on the execution-time type of the target of the call; there's no target for static method calls, as such.

    No, subclasses can't override final methods - the whole point of making a method final is to prevent it from being overridden.

    0 讨论(0)
提交回复
热议问题