ee9553
asked on
Calling method within an inheritance tree
Hello experts,
If I have a class
BaseClass extends Panel
public static String getString(){
}
another class
BaseGridPanel extends BaseClass
another class
Inbox extends BaseGridPanel
Now.. The question is if I call method in BaseClass like this
BaseGridPanel.getString();
and NOT like
BasePanel.getString();
Why would the program still compiled.
If I have a class
BaseClass extends Panel
public static String getString(){
}
another class
BaseGridPanel extends BaseClass
another class
Inbox extends BaseGridPanel
Now.. The question is if I call method in BaseClass like this
BaseGridPanel.getString();
and NOT like
BasePanel.getString();
Why would the program still compiled.
ASKER
Edited text of question.
ASKER
Edited text of question.
because getString is a static method.
BaseGridClass inherits the method, and unless you override it will pass calls to it up the inheritance chain until it reaches a solid implementation of it.
it compiles because that's what it's meant to do. it means that if you extend a class which has static methods, you can call them from your subclass still.
BaseGridClass inherits the method, and unless you override it will pass calls to it up the inheritance chain until it reaches a solid implementation of it.
it compiles because that's what it's meant to do. it means that if you extend a class which has static methods, you can call them from your subclass still.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you BillyAbbott and mjenkins for posting the comments.
For BillyAbbott, please lock the null question which I will posted. You do deserve some points
Thanks
For BillyAbbott, please lock the null question which I will posted. You do deserve some points
Thanks
ASKER