简体   繁体   中英

override of static method and final method

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

Two questions:

1. Why is that? Could anyone explain me the reason inside it?

2. Can subclass override final method in super class then?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM