This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Method invocation

 
Sudhanshu Mishra
Ranch Hand
Posts: 236
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 20902
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic