wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Method invocation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Method invocation" Watch "Method invocation" New topic
Author

Method invocation

Sudhanshu Mishra
Ranch Hand

Joined: May 28, 2011
Posts: 215

Hi all,
I am a bit confused about the way method invocation works.
Do we really need an object for the method invocation at all times or it is just at the time of method overriding that the JVM will look at the real object type.I am not convinced with this fact.What happens if their is no overriding at all?how does the method invocatin tkes place then.

I have recieved few answers but I am not convinced.I have always read that an object is required for method invocation and the JVM always looks at the real object type while method invocation.

Please clear my concept.

Thanks....
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18523
    
  40

Sudhanshu Mishra wrote:Hi all,
I am a bit confused about the way method invocation works.
Do we really need an object for the method invocation at all times or it is just at the time of method overriding that the JVM will look at the real object type.I am not convinced with this fact.What happens if their is no overriding at all?how does the method invocatin tkes place then.


Basically, to call a static method, then no. To call an instance method (ie. non-static method), then yes. And of course, the reason is because an instance method, has access to its this object, so you need to actually provide one.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
jQuery in Action, 2nd edition
 
subject: Method invocation
 
Similar Threads
Static initializer doesn't return value.
confused with the output from a code (Arrays)
Can anyone see this...
Polymorphism! correct me if i am wrong.
Method invocation without Object