Link to home
Start Free TrialLog in
Avatar of ee9553
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.



Avatar of ee9553
ee9553

ASKER

Edited text of question.
Avatar of ee9553

ASKER

Edited text of question.
Avatar of ee9553

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.
ASKER CERTIFIED SOLUTION
Avatar of mjenkins
mjenkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ee9553

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