method are not stored in object but can be called from object?

hi , can i have an explanation of this statement if is not stored in object then where dose it got stored
8 Replies
Yawnder
Yawnder4d ago
Sorry, I misclicked the reactions. The methods aren't stored in the object, they're stored in the class definition. So for example, if you have 1000 instances of a class that has 8 bytes of data, but a method that takes 500 bytes, it wouldn't take 1000 x 508 bytes.
steven preadly
steven preadlyOP4d ago
this means that a class has its own memory correct on the heap
Yawnder
Yawnder4d ago
Yes and no. The memory isn't fixed at the startup of the program for example. The memory where a class definition resides could change over the course of the execution of the program from what I understand.
steven preadly
steven preadlyOP4d ago
this is where the confision comes
Yawnder
Yawnder4d ago
How so?
steven preadly
steven preadlyOP3d ago
when we said class may or may not have its own memory
Yawnder
Yawnder3d ago
Unless you elaborate on what you actually want to know, or what that question evenly is, I'll just move on.
steven preadly
steven preadlyOP3d ago
any ways thank you

Did you find this page helpful?