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
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply 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: 20
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://jrebel.com/download
 
subject: Overriding
 
Similar Threads
Confused help me!!
Marcus Green test1 Q16
call to shadowed static method at runtime!!!
Another mock exam question.
A question from sarga.com