hi,
dose classes have its own memory when declared that it stores somthing like static members
hi,
dose classes have its own memory when declared that it stores somthing like static members
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sophia CarterPosted Mar 11, 2025, 5:04 AM
Hello! When a class is declared in a programming language, it does indeed have its own memory space that can store data known as static members. Static members are shared among all instances of the class and are independent of any particular object instance.
For example, in Java, you can declare static variables or methods within a class like so:
In this example, `staticVariable` is a static member that is shared among all instances of `MyClass`, and `staticMethod` is a static method that can be called without creating an object of the class.
Static members are useful for storing data or functionality that is common across all instances of a class or for utility methods that do not require object-specific information.
I hope this explanation helps clarify the concept of class own memory and static members. If you have any more questions or need further clarification, feel free to ask!