wood burning stoves 2.0*
The moose likes Java in General and the fly likes static confusion? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "static confusion?" Watch "static confusion?" New topic
Author

static confusion?

Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1268

Hi I am confused static method... As per my knowledge static method neither verride nor overload but still we can inherit it.. ohk fine as per the inheritance concept if we follow that didn't it gives ambiguity in the code(which method call when??)


No Kaustubh No Fun, Know Kaustubh Know Fun..
Vinoth Kumar Kannan
Ranch Hand

Joined: Aug 19, 2009
Posts: 276

Check out this - http://faq.javaranch.com/java/OverridingVsHiding. May be this is what you want.


OCPJP 6
Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1268

Thanks vinoth...

but still have doubt ...

what in case of we directly call this static method with object...i.e.



is the compiler replace this
new obj
with some reference variable...
Vinoth Kumar Kannan
Ranch Hand

Joined: Aug 19, 2009
Posts: 276

Static methods to be called doesn't require a instance. Even if you provide an instance for invoking, the JVM will only fetch the associated reference and call the static method on it.
new Obj() will return a reference the Obj class(obviously). JVM will use it to make the static call.
akhter wahab
Ranch Hand

Joined: Mar 02, 2009
Posts: 151

Vinoth Kumar Kannan wrote:Check out this - http://faq.javaranch.com/java/OverridingVsHiding. May be this is what you want.


nice tutorial


Start Earning Online||Start Earning Using Java
Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1268

Thank you very much vinoth

Thanks akhter for revision

kaustubh
Vinoth Kumar Kannan
Ranch Hand

Joined: Aug 19, 2009
Posts: 276

You're welcome!
Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1268

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: static confusion?
 
Similar Threads
inquisition question
can we use a local variable inside the static method
Class.forName()
Static Methods in an Interface
inheriting a static method.....