| Author |
static confusion?
|
Kaustubh G Sharma
Ranch Hand
Joined: May 13, 2010
Posts: 1145
|
|
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: 1145
|
|
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
|
|
nice tutorial
|
Start Earning Online||Start Earning Using Java
|
 |
Kaustubh G Sharma
Ranch Hand
Joined: May 13, 2010
Posts: 1145
|
|
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: 1145
|
|
|
 |
 |
|
|
subject: static confusion?
|
|
|