Are static methods inherited in Java?

后端 未结 14 1379
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 05:08

I was reading A Programmer’s Guide to Java™ SCJP Certification by Khalid Mughal.

In the Inheritance chapter, it explains that

Inherit

14条回答
  •  别跟我提以往
    2020-11-22 05:58

    If that's what the book really says, it's wrong.[1]

    The Java Language Specification #8.4.8 states:

    8.4.8 Inheritance, Overriding, and Hiding

    A class C inherits from its direct superclass all concrete methods m (both static and instance) of the superclass for which all of the following are true:

    • m is a member of the direct superclass of C.

    • m is public, protected, or declared with package access in the same package as C.

    • No method declared in C has a signature that is a subsignature (§8.4.2) of the signature of m.

    [1] It doesn't say that in my copy, 1st edition, 2000.

提交回复
热议问题