This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Method invocation

 
Sudhanshu Mishra
Ranch Hand
Posts: 235
1
Eclipse IDE Fedora Java
  • 0
  • 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: 20836
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic