Static Methods

Static Methods

Information related to Static Methods are discussed here.

Are Static Methods Inherited?

Yes. They are. A good example is here (taken from JavaRanch http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=24&t=039264&p=1)

class Main
{
    public static void main(String args[])
    {
         System.out.println("Hi");
    }
}
public class Main2 extends Main
{
}

When you run the above code with the following line

java Main2

Perfectly, the output would be

Hi

This shows the static main() method is indeed inherited and available.

This is NOT in scope for SCJP exam. - Info given by Bert Bates - the co-author of SCJP book (Kathy Sierra & Bert Bates).

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.