Hi,
Somewhere i read that, static methods will not be overriden, because static methods will not be inherited even they are public. Then, observe the below programme,
--------
1class P {
2 static void printS1(){System.out.print("P.printS1 ");}
3 void printS2() {System.out.print("P.printS2 ");}
4 void printS1S2(){printS1();printS2();}
5}
6public class D extends P {
8 void printS2(){System.out.print("Q.printS2 ");}
9 void printS1S2(){printS1();printS2();}
10
11
12 public static void main(
String[] args) {
13 new D().printS1S2();
14}}
output - P.printS1 Q.printS2
--------------
In line number 9 of subclass D, i am invoking the method called, printS1(), which is a static method declared in the super class. If static methods are not inherited, then how the above progrmme is compiling and giving the below output.P.printS1 Q.printS2
Thanks,
Narasimha.