File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Overriding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Overriding" Watch "Overriding" New topic
Author

Overriding

sandhi mridul
Ranch Hand

Joined: Jan 25, 2008
Posts: 71
Hi,
there are 2 programs only diffre in the static n non static.


Ans= Base.test()

another code



ans= Child.test()

My question is why the calling method class is getting change means at one place its Base class however at other its child class. What is the reason behind.

please explain me the how the call is going for a static method and nonstatic method?

Thanks
Sandhya
Sergio Calvo
Greenhorn

Joined: Feb 22, 2008
Posts: 8
See here: http://faq.javaranch.com/view?OverridingVsHiding
Chethan C Gowda
Greenhorn

Joined: Dec 06, 2007
Posts: 22
While calling static methods compiler checks for reference type not the obect type.
In example 1 you are calling static method using Base class reference, where as while calling instance method compiler checks for object type.


Thanks,
Chethan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Overriding