Can main method be inherited ?
If a super class has a main method and sub
class doesn't have it, will the main method of
the superclass is called ?
The best way to answer this question is to try it and see. It never fails to amaze me how often question like this get posted - it would probably be quicker and easier to just test than to come here, ask the question and wait for an answer. If you can't even manage that much on your own, then you aren't going to get very far as a Java developer.
By all means, once you've tried it for yourself, feel free to come here and ask about the results if they surprised you or you don't understand them, but asking "
What would happen if I did this", when its something you could just do and find out, makes you seem a little pathetic (IMHO).
can you just explain it more clearly ?
Explain what more clearly? You asked a yes/no question and got an answer (yes).
As far as I
know the static methods cannot be inherited
Well whoever told you that got it wrong.
A better question to have asked today might have been:
"
I read last week that static methods aren't inherited, but I wrote some code that seems to demonstrate that in fact they are. At first I thought it was just the main method but then I tried with other static methods and found the same thing happened. Is it a special circumstance with certain static methods that I've stumbled across, or is what I was told last week just plain wrong? Here's some code to demonstrate what I did: <your code here>"