Cleared SCJP 1.5 | Cleared SCWCD 5.0
SCDJWS 6 in progress.....
Preparing for SCJP 6.0
http://java.sun.com/docs/books/tutorial/java/IandI/override.html
Bittoo,
You are talking about OVERRIDING, which deals about DIFFERENTLY-DEFINING a parent class's method in the child class, which is different from just calling a parent class function in the class. You have done the 2nd thing (just a call...You can call a static method of the parent class in your subclass without issues...)
But, in your example, if you override the function display() in your subclass, you will get a compiler error that says something like "you are overriding a static method which is not possible".
Check out the following code for this error:
code:
--------------------------------------------------------------------------------
class parent{public static void display(){System.out.println("Hi I am static method in parent class");}}public class subclass extends parent{public void display (){System.out.println ("In subclass");}public static void main(String args[]){subclass s = new subclass();s.display();}}
--------------------------------------------------------------------------------
the second thing is that static method and variable will not be inherited but that will be overhide
------------------------
Bob
SCJP - 86% - June 11, 2009
Thanks<br /> <br />Anoobkumar<br />SCJP 1.5
SCJP 5, SCWCD 5, SCBCD 5