posted 19 years ago
You can redefine the base class static method in your derived class, however this would not be overriding.
For example, assume you have a static method- static void f()- in your base class as well as the derived class, and you invoke it as shown.
Base b=new Derived();
b.f(); // this will invoke the method in the base class only
This is because static methods belong to the class and not to the object, and cannot be overridden. The method invoked is chosen according to the declared type of the reference variable.
Also, note that base class static methods cannot be redefined in the derived class as non static and vice versa. This will cause a compile time error.
Thanks,
Seema
Seema Manivannan<br />Author and Trainer: Java Certifications<br /> <br />Whizlabs Software<br />Success, certified!<br />Global leader: J2EE certification exam preparation!<br /><a href="http://www.whizlabs.com" target="_blank" rel="nofollow">http://www.whizlabs.com</a><br /> <br />An ISO 9001-2000 certified company!