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
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.
this means that a class has its own memory correct on the heap
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.
this is where the confision comes
How so?
when we said class may or may not have its own memory
Unless you elaborate on what you actually want to know, or what that question evenly is, I'll just move on.
any ways thank you