Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Calling method within an inheritance tree

Posted on 1999-07-21
6
Medium Priority
?
224 Views
Last Modified: 2010-04-16
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.



0
Comment
Question by:ee9553
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 

Author Comment

by:ee9553
ID: 1246664
Edited text of question.
0
 

Author Comment

by:ee9553
ID: 1246665
Edited text of question.
0
 

Author Comment

by:ee9553
ID: 1246666
Edited text of question.
0
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 
LVL 1

Expert Comment

by:BillyAbbott
ID: 1246667
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.
0
 
LVL 3

Accepted Solution

by:
mjenkins earned 40 total points
ID: 1246668
Static methods are inherited. Your BaseGridPanel IS A BasePanel. So the call to BaseGridPanel.getString() is equivalent to BasePanel.getString(). THe only difference would be that if you override getString in BaseGridPanel, the method from the named class will be called.
0
 

Author Comment

by:ee9553
ID: 1246669
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
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question