Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how java allocates space for objects methods

 
Anil Deshpande
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I don't know whether this question is right?


Say I have a class Animal and have created three objects of that class type.


I want to know whether all objects a,b,c share same method in jvm memory space or each object have their own copy of method1
 
Ramasamy Anbalagan
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anil,

Each object having their own copy of Method1 string value.
 
Muhammad usman shad
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear,
All the objects will share same copy........
If you make any change in the method,
It will affect on all the objects...
So, changing in one method affecting all the objects means that all the objects share same copy....
Right...
 
Campbell Ritchie
Sheriff
Pie
Posts: 48957
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you need to know that in the first place?

I know it is a bit out of date, but the BCEL handbook is a good starting-point for such questions.
 
Anil Deshpande
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My friend had recently attended a interview for a teaching faculty job.

This question was asked to him. He exactly said that all objects share the same copy of the method.Even I had agreed to him. The person who was doing the interview disagreed.

So I wanted to confirm the answer.

Thanks a lot for clarifying.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48957
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, what did your friend say when given incorrect information in an interview?
 
Anil Deshpande
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't know, have to ask him
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic