File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

object member

 
Yasir Qureshi
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Today I gave an interview, one question i was asked is that " when object is created each object got different copy of data member (non static), does all objects have their own copy of non static methods"
I replied no only data memebers r contained not methods, AM I RIGHT.
Yasir Sufyan
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Yasir,
IMO, you are right. Instance methods are defined as:
A method which belongs to an instance of the class. Objects of the same class share its implementation.
Regards,
Manfred.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Methods, static and non-static, are held in the Method area that is created one time at Class Load time. They are in no way involved with the instance objects that are on the heap.
Objects ONLY hold the values of the fields (member variables) which define the STATE of the object, NOT the behaviors of the object.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic